相关疑难解决方法(0)

在 webstorm 中显示项目范围的 TypeScript 问题/错误

有没有办法让Webstorm在不打开所有文件的情况下连续报告项目范围内的所有打字稿错误?出于性能原因,我希望使用语言服务来完成它,而不是通过运行 tsc 的任务来完成。

我知道 Webstorm 使用 Dart 分析服务器显示了 Dart 项目中的所有问题,我认为它类似于 Typescript 语言服务。因此,基本上我正在寻找一种方法,使 Webstorm(或 vscode)在报告项目范围错误方面与 TypeScript 的工作方式与 Dart 项目的工作方式相同。

2016年9月9日编辑:

Webstorm 中的一个小例子:

  • 文件>新建项目>空项目
  • 配置 Webstorm > 首选项 > 语言和框架 > TypeScript
  • 检查使用 TypeScript 服务(实验性)
  • 选中启用 TypeScript 编译器
  • 检查跟踪更改
  • 范围:项目文件
  • 选择手动设置选项
  • 命令行选项:--noEmit

添加这些文件:

测试1.ts

export const foo:number = 5;
Run Code Online (Sandbox Code Playgroud)

测试2.ts

import {foo} from './test1';
const bar:string = foo;
Run Code Online (Sandbox Code Playgroud)
  • 关闭所有文档并退出 Webstorm。
  • 重新启动网络风暴。
  • 打开文件 test1.ts。
  • 检查“当前错误”和“项目错误”窗格,它们都是空白的。
  • 按“全部编译”按钮。
  • 当前错误:空白(为什么?)
  • 项目错误:test2.ts > 错误:(3, 7) TS2322:类型“数字”无法分配给类型“字符串”。

现在将 test1.ts 的内容更改为:

export const foo:string = "";
Run Code Online (Sandbox Code Playgroud)

保存 test1.ts。

  • “当前错误”和“项目错误”都与以前相同。 …

webstorm typescript visual-studio-code

5
推荐指数
1
解决办法
7054
查看次数

如果文件未打开,Vscode 不会显示打字稿错误

我在本机反应上使用打字稿。当我的某个文件中有错误时,vscode 不会在“问题”选项卡中显示它,除非我打开了该文件。

打开文件之前: 文件未打开

打开文件后: 文件已打开

tsconfig.json:

{
  "extends": "@tsconfig/react-native/tsconfig.json"
}
Run Code Online (Sandbox Code Playgroud)

@tsconfig/react-native/tsconfig.json:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "React Native",
  "_version": "2.0.3",
  "compilerOptions": {
    "target": "esnext",
    "module": "commonjs",
    "types": ["react-native", "jest"],
    "lib": [
      "es2019"
    ],
    "allowJs": true,
    "jsx": "react-native",
    "noEmit": true,
    "isolatedModules": true,
    "strict": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  },
  "exclude": [
    "node_modules",
    "babel.config.js",
    "metro.config.js",
    "jest.config.js"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能使所有错误都显示在问题选项卡中并且侧栏中的文件具有红色下划线?

typescript visual-studio-code

4
推荐指数
1
解决办法
1215
查看次数

VSCode 的“打开文件夹时运行”任务中的“打开文件夹时”是什么意思?

VSCode 去年添加了一项功能,可以在“打开文件夹时”自动运行任务。但是在使用工作区时“打开文件夹”是什么意思?

具体来说,如果你打开一个工作区,"runOn": "folderOpen"任务会运行吗?如果是这样,如何?

我之所以这么问是因为我将任务配置为自动运行,但是当我打开工作区时它没有运行。(任务在手动触发时正确运行。)

visual-studio-code vscode-tasks

1
推荐指数
1
解决办法
769
查看次数