Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: a --noEmitJS compiler option #15158

Closed
mcmath opened this issue Apr 12, 2017 · 2 comments · Fixed by #20735
Closed

Suggestion: a --noEmitJS compiler option #15158

mcmath opened this issue Apr 12, 2017 · 2 comments · Fixed by #20735
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript

Comments

@mcmath
Copy link

mcmath commented Apr 12, 2017

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.

@mhegazy
Copy link
Contributor

mhegazy commented May 11, 2017

Duplicate of #13318

@mhegazy mhegazy closed this as completed May 11, 2017
@mhegazy mhegazy added the Duplicate An existing issue was already created label May 11, 2017
@nojvek
Copy link
Contributor

nojvek commented Dec 16, 2017

@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.

@mhegazy mhegazy added this to the TypeScript 2.8 milestone Jan 25, 2018
@mhegazy mhegazy added Fixed A PR has been merged for this issue Suggestion An idea for TypeScript and removed Duplicate An existing issue was already created labels Jan 25, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants