sunknudsen
sunknudsen

Reputation: 7310

Is it necessary to exclude node_modules when src is set in tsconfig.json?

Most boilerplate I find includes "exclude": ["node_modules"] but this property appears to be unnecessary given "include": ["src"] (node_modules being outside of src). Am I missing something?

{
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "noFallthroughCasesInSwitch": true,
    "outDir": "lib",
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es5"
  },
  "exclude": ["node_modules"],
  "include": ["src"]
}

Upvotes: 0

Views: 150

Answers (1)

Aleksey L.
Aleksey L.

Reputation: 38046

No, it is not necessary because

  1. "node_modules" is one of the patterns excluded by default
  2. "exclude" specifies an array of filenames or patterns that should be skipped when resolving "include" (and as you pointed out it is out of src anyway)

Docs

Upvotes: 1

Related Questions