Typescript Useful Compilation Options
If you’re using typescript (tsc) to compile your typescript files, there are some handy compilation options that can give you more insight into how compilation happens or why certain files are compiled.
Using the tsconfig.json you can change what the output directory or location
of the built javascript is. Sometimes if you’re changing that location it can
be tedious to go back and delete all the files that were built. Use the --build
flag along with the --clean flags to delete all the built javascript files.
# delete all built javascript files
tsc --build --cleanWant to see the typescript files that are being built from in your codebase?
Use the --listFiles to build and also output a list of the files that were used
to build your javascript.
# list all the source typescript files being used to build your javascript
tsc --listFilesWith the tsconfig.json compilerOptions
module setting you can set how the compiler decides to what to import. You can see
the log output of this process by using the --traceResolution flag. This verbose
output can be useful if there is a problem with some files being compiled that you
don’t want or if you want to decide which module pattern you want to use in your
compilerOptions.
# see output of the module resolution from typescript
npx tsc --traceResolutionRead more about it here