Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude directories from being watched in TypeScript

Tags:

typescript

--watch is a neat feature during development. However, in my app I upload files to a directory named tmp. Whenever a file has been uploaded to this directory my app re-compiles which leads to all kinds of problems. I want to exclude tmp from being watched.

What I have tried so far is adding tmp to the "exclude": property in tsconfig.json, but this does not help.

I have looked at the documentation but I can't find any info on how to do this. https://www.typescriptlang.org/docs/handbook/configuring-watch.html

Is what I'm trying to achieve possible?

like image 977
Slamdunk Avatar asked Nov 28 '25 23:11

Slamdunk


1 Answers

I actually have this working with the exclude on tsconfig like this:

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "preserveConstEnums": true,
    "strict": true,
    "target": "es2017",
    "baseUrl": ".",
  },
  "exclude": ["__tests__"]
}

When i change any file on my __tests__ folder it will not compile again with watch mode.

NOTE: I'm using the latest tsc

like image 167
dege Avatar answered Nov 30 '25 20:11

dege



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!