I've been experimenting with different settings in my tsconfig.json
. As part of this, I want to re-compile all my TypeScript files to see how the emitted JavaScript differs with the new settings (e.g. changing the module
option).
The underlying .ts
files themselves haven't changed, however, and so calling tsc
does nothing.
How can I tell tsc
to recreate all the files even though it thinks it doesn't need to?
For reference, I'm invoking the TypeScript compiler like so:
node_modules/typescript/bin/tsc --build src/tsconfig.json
I discovered the answer - although tsc
doesn't have a "top-level" force option, since I'm already using the --build
option, I can pass --force
to that:
node_modules/typescript/bin/tsc --build --force src/tsconfig.json
From the documentation:
There are also some flags specific to
tsc -b
: [...]
--force
: Act as if all projects are out of date
As a follow to Sam's answer, in the specific case you have the incremental flag set to true
(the default) you can also delete the .tsbuildinfo
file created by Typescript. This contains metadata about what files are / are not up to date. Without this data, tsc -b
will re-compile your entire project.
Incremental flag docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With