Reputation: 193302
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, e.g.
"ts001test": "./node_modules/.bin/ts-node --skip-project scripts/ts_codeExamples/ts001_test.ts"
which works fine. (--skip-project
prevents ts-node rom loading the .tsconfig
file)
However, when two of these scripts have the same variable, VSCode complains that I cannot redeclare the same variable that is in another file.
How can I tell VSCode to treat each of these TypeScript files with their own individual scope and not look in other files to see if variables have been used elsewhere?
Upvotes: 1
Views: 238
Reputation: 193302
I solved this problem by putting the following line at the beginning of each TypeScript script:
export {};
as mentioned in this article:
TypeScript decided to solve the problem by simply stating that a module is any file which contains an import or export.
Upvotes: 2