You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
@mhegazy I understand you've marked this as duplicate of --removeComments option but it doesn't seem like a duplicate. Generating only .d.ts files is a very legit use-case. noEmitJs becomes even more useful when you want to generate typings for pure js project with checkJs, declarations and allowJs enabled.
I understand allowJs + declarations is not supported but I understand it will soon be supported.
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: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.
The text was updated successfully, but these errors were encountered: