I am working with the excellent Express/Node/Typescript example code found here. It transpiles the .ts code with the following command from run.sh:
./node_modules/.bin/tsc --sourcemap --module commonjs ./bin/www.ts
This works as advertised, but I would prefer to use a tsconfig.json file and tsc -p .
However, when I run that command I get a raft of TS2300: Duplicate identifier 'foo' errors
when tsc
(erroneously?) tries to walk the ./node_modules
and ./typings
directories. Below is the tsconfig.json I am using:
{ "compilerOptions": { "target": "ES5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings" ] }
Any ideas? I am using tsc 1.7.3 FWIW.
Use the exclude option in your tsconfig. json file to exclude a folder from compilation in TypeScript. The exclude option changes what the include setting finds and defaults to node_modules and bower_components .
The tsconfig. json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig. json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.
ts-node supports a variety of options which can be specified via tsconfig. json , as CLI flags, as environment variables, or programmatically.
In a similar vein I was having issues with node_modules
exclusion.
Here's a heavy handed solution, that ignores all *.d.ts
files.
I added to compilerOptions
:
"compilerOptions": { "skipLibCheck": true, ... }
Related:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With