![](/img/trans.png)
[英]How to get VSCode to show TypeScript errors for files *not* open in the editor?
[英]How to make VSCode show me strictNullChecks Typescript errors
当我使用以下tsconfig.json
构建我的项目时,由于最近添加了strictNullChecks: true
而出现错误。
{
"version": "2.3.4",
"compilerOptions": {
"allowSyntheticDefaultImports": false,
"removeComments": true,
"strictNullChecks": true,
"sourceMap": true,
"jsx": "react",
"target": "es5",
"lib": [
"es6",
"dom",
"scripthost"
],
"outDir": "../build/"
},
"include": [
"./*.ts",
"./*.tsx",
"./{client,mobile,server,shared,test,tools}/*.ts",
"./{client,mobile,server,shared,test,tools}/*.tsx",
"./{client,mobile,server,shared,test,tools}/**/*.ts",
"./{client,mobile,server,shared,test,tools}/**/*.tsx",
"./desktop/*.ts"
]
}
但是,我在 VSCode 中没有看到任何错误。
我还有以下 vscode 设置:
"typescript.tsdk": "./node_modules/typescript/lib",
除了strictNullChecks 错误外,一切似乎在 VSCode 中都运行良好。
检查文件是否未被tsconfig.json
中的include
或exclude
规则排除。
可能的情况包括:
*.ts
、 ./*.ts
或其他变体,而不是**/*.ts
)。 这似乎是原始问题中的问题。include
规则,之前没有规则存在 - 在此处指定任何值将覆盖默认值**/*.*
。感谢 Matt Bierner 在对该问题的评论中提供提示。 但是,它没有作为答案发布,因此没有适当的可见性或突出性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.