在 webstorm 中显示项目范围内的 TypeScript 问题/错误 [英] Show project wide TypeScript problems/errors in webstorm
问题描述
有没有办法让 Webstorm 在不打开所有文件的情况下连续报告项目范围内的所有打字稿错误?出于性能原因,我希望使用语言服务而不是运行 tsc 的任务来完成.
Is there any way to make Webstorm continuously report all typescript errors project wide without opening all the files? For performance reasons I would like it done using the language service and not by a task running tsc.
我知道 Webstorm 使用 Dart 分析服务器显示 Dart 项目中的所有问题,我认为这类似于 Typescript 语言服务.所以基本上我正在寻找一种方法,让 Webstorm(或 vscode)在 TypeScript 中的工作方式与 Dart 项目在报告项目范围错误方面的工作方式相同.
I know Webstorm shows all problems in Dart projects using the Dart analysis server which I think is similar to the Typescript language service. So basically I am looking for a way to make Webstorm (or vscode) work the same way for TypeScript as it does for Dart projects with regards to reporting project wide errors.
编辑 2016-09-09:
Edit 2016-09-09:
Webstorm 中的一个小例子:
A small example in Webstorm:
- 文件 > 新建项目 > 空项目
- 配置 Webstorm > 首选项 > 语言 &框架 > TypeScript
- 检查使用 TypeScript 服务(实验性)
- 选中启用 TypeScript 编译器
- 检查跟踪更改
- 范围:项目文件
- 选择手动设置选项
- 命令行选项:--noEmit
添加这些文件:
test1.ts
export const foo:number = 5;
test2.ts
import {foo} from './test1';
const bar:string = foo;
- 关闭所有文档并退出 Webstorm.
- 重启 Webstorm.
- 打开文件 test1.ts.
- 检查当前错误"和项目错误"窗格,它们都是空白的.
- 按全部编译"按钮.
- 当前错误:空白(为什么?)
- 项目错误:test2.ts > 错误:(3, 7) TS2322:类型数字"不可分配给类型字符串".
现在把 test1.ts 的内容改成这样:
Now change the contents of test1.ts to this:
export const foo:string = "";
保存 test1.ts.
Save test1.ts.
- 当前错误"和项目错误"都与之前相同.
- 在这里,我希望窗格被清除,因为 test2.ts 中的错误已修复,但由于 test2.ts 未在编辑器中打开,它似乎没有更新.
- 按下编译所有按钮.
- 现在当前错误"和项目错误"都被清除了.
推荐答案
在 Webstorm 上,Typescript ->当前错误
选项卡显示实时"项目范围的错误
On Webstorm, the Typescript -> Current Errors
tab displays project wide errors 'live'
引入或修复错误,结果将显示在该选项卡中.
Introduce or fix an error and the result will appear in that tab.
Typescript 首选项必须正确设置;WS 在下面的示例中使用项目 tsconfig.json.全部编译"必须至少从该选项卡运行一次(我猜是为了构建错误缓存)
Typescript preferences must correctly be set; WS is using the project tsconfig.json in the example below. A 'Compile All' must be run from that tab at least once (to build the errors cache, I guess)
这篇关于在 webstorm 中显示项目范围内的 TypeScript 问题/错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!