如何让 Visual Studio Code 真正显示所有 TypeScript 类型错误? [英] How to make Visual Studio Code show really all TypeScript type errors?
问题描述
在我的 TypeScript/React 项目中,react-scripts start"显示了未在我的 Visual Studio Code IDE 中内嵌显示的类型错误.大多数类型错误实际上是内联显示的,但不是全部.那可能是什么原因?如何让 Visual Studio Code 直接显示所有错误?
In my TypeScript/React project, "react-scripts start" shows type errors that are not shown inline in my Visual Studio Code IDE. Most types errors are actually shown inline, but not all. What could be the reason for that? How can I make Visual Studio Code show all errors directly?
VS Code 设置 "typescript.validate.enable" 设置为 true
VS Code setting "typescript.validate.enable" is set to true
我的 tsconfig.json:
My tsconfig.json:
{
...
"compilerOptions": {
....
"noImplicitAny": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
...
}
...
}
推荐答案
我不太确定这是否是您问题的解决方案,但对我来说,我经常遇到类似您在 VSCODE 运行时所描述的问题与您的构建版本不同.
I'm not quite sure if this is the solution to your issue, but for me I often get issues like the ones you're describing when VSCODE is running on a different version than your build is.
在右下角,您可以选择要在 Visual Studio Code 中使用的版本:
Down in the right corner, you can select which version you want to use in Visual Studio Code:
只需单击版本号(图片中为 3.0.3)并从您的工作区中选择版本,而不是在 vscode 中安装的最新版本!
Simply click the version number (3.0.3 in image) and select the version from your workspace instead of the latest installed in vscode!
这篇关于如何让 Visual Studio Code 真正显示所有 TypeScript 类型错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!