Description
The problem
It is sometimes useful to set different compiler options for .js
files and .d.ts
files. For example, I often want to set --removeComments
for JavaScript outputs but not for declaration files. This can currently be achieved by building a project with --declaration
and --removeComments
enabled, removing emitted .js
files, and then building the project without those options:
tsc --declaration --removeComments && rimraf "dest/**/*.js" && tsc
This is convoluted and wasteful. Of course, there are always tools like Gulp, but it would be nice to have a solution using just the tsc
command.
A solution: a --noEmitJS compiler option
I would like to see a --noEmitJS
compiler option. Like --noEmit
, it would suppress emitted JavaScript files, but unlike --noEmit
, it would still emit sourcemaps and declaration files if the relevant compiler options are enabled. The above could be achieved like so:
tsc && tsc --declaration --removeComents --noEmitJS
This is nicer. It would also cover any other scenarios where different options are required for either declarations or sourcemaps.