繁体   English   中英

如何让 VSCode 不检查目录中的 other.ts 文件是否存在变量冲突?

[英]How to get VSCode to not check other .ts files in directory for variable conflicts?

I have a React app with a directory of TypeScript scripts which I use to run admin tasks, etc. I execute them with npm scripts in the package.json file, eg

"ts001test": "./node_modules/.bin/ts-node --skip-project scripts/ts_codeExamples/ts001_test.ts"

效果很好。 --skip-project阻止 ts-node rom 加载.tsconfig文件)

但是,当其中两个脚本具有相同的变量时, VSCode 会抱怨我无法重新声明另一个文件中的相同变量

我如何告诉 VSCode 将这些 TypeScript 文件中的每一个文件与它们自己的 scope 一起处理,而不是查看其他文件以查看变量是否已在其他地方使用?

在此处输入图像描述

我通过在每个 TypeScript 脚本的开头添加以下行来解决这个问题:

export {};

本文所述

TypeScript 决定通过简单地说明模块是包含导入或导出的任何文件来解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM