Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"exclude" property of tsconfig.json is not being respected

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' errorswhen 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.

like image 472
Ken Avatar asked Dec 16 '15 12:12

Ken


People also ask

What should I exclude in Tsconfig?

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 .

What is Tsconfig Lib json?

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.

Does TS node use Tsconfig json?

ts-node supports a variety of options which can be specified via tsconfig. json , as CLI flags, as environment variables, or programmatically.


1 Answers

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:

  • https://www.typescriptlang.org/tsconfig#compilerOptions
like image 179
jmunsch Avatar answered Oct 04 '22 04:10

jmunsch