有没有办法让Webstorm在不打开所有文件的情况下连续报告项目范围内的所有打字稿错误?出于性能原因,我希望使用语言服务来完成它,而不是通过运行 tsc 的任务来完成。
我知道 Webstorm 使用 Dart 分析服务器显示了 Dart 项目中的所有问题,我认为它类似于 Typescript 语言服务。因此,基本上我正在寻找一种方法,使 Webstorm(或 vscode)在报告项目范围错误方面与 TypeScript 的工作方式与 Dart 项目的工作方式相同。
2016年9月9日编辑:
Webstorm 中的一个小例子:
添加这些文件:
测试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)
现在将 test1.ts 的内容更改为:
export const foo:string = "";
Run Code Online (Sandbox Code Playgroud)
保存 test1.ts。
我在本机反应上使用打字稿。当我的某个文件中有错误时,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)
我该怎么做才能使所有错误都显示在问题选项卡中并且侧栏中的文件具有红色下划线?
VSCode 去年添加了一项功能,可以在“打开文件夹时”自动运行任务。但是在使用工作区时“打开文件夹”是什么意思?
具体来说,如果你打开一个工作区,"runOn": "folderOpen"任务会运行吗?如果是这样,如何?
我之所以这么问是因为我将任务配置为自动运行,但是当我打开工作区时它没有运行。(任务在手动触发时正确运行。)