Skip to content

Instantly share code, notes, and snippets.

@strarsis
Last active March 5, 2022 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strarsis/820079734a00508aa9e73518274d465d to your computer and use it in GitHub Desktop.
Save strarsis/820079734a00508aa9e73518274d465d to your computer and use it in GitHub Desktop.
Make TypeScript ignore all other directories than e.g. `src/`

TypeScript can have issues with with more folders containing TypeScript files than just the one used as rootDir, (e.g. migrations/ for Knex). (E.g. see this now archived/locked issue microsoft/TypeScript#9858).

The exclude option in tsconfig.json won't prevent this issue. Instead use the include option and include only the rootDir folder.

Example (showing only the relevant fields):

{
  "compilerOptions": {
    "rootDir": "./src"
  },
  "include": [
    "./src"
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment