Skip to content

Suggestion: a --noEmitJS compiler option #15158

Closed
@mcmath

Description

@mcmath

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions