geeko
geeko

Reputation: 2852

Excluding node_module when using include in tsconfig.json?

I see a lot of people are excluding node_modules in thier tsconfig.json. I am using include with specific folder patterns. Do I still need to exclude node_modules? How about third-party libraries that are not compiled into JS (i.e. included in my project as TS)?

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": ".",
    "declaration": true,
    "declarationDir": "builds",
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "jsx": "preserve",
    "jsxFactory": "Vue",
    "lib": ["dom", "dom.iterable", "esnext", "scripthost"],
    "module": "esnext",
    "moduleResolution": "node",
    "paths": {
      "@/*": ["*"]
    },
    "sourceMap": true,
    "strict": true,
    "target": "esnext",
    "types": ["jest", "node", "vuetify", "webpack-env"],
    "typeRoots": ["node_modules/@types"]
  },
  "include": [
    "codes/**/*.ts",
    "codes/**/*.tsx",
    "shims/**/*.ts"
  ]
}

Upvotes: 0

Views: 1185

Answers (1)

teimurjan
teimurjan

Reputation: 1975

The reason for excluding node_modules is the independence of your compiler from the libraries as any package should be compiled to JS. If a package does not have the compiled version, I'd consider it unsafe.

Upvotes: 1

Related Questions