microsoft / microsoft/TypeScript

Allow '--noEmit' to override 'emitDeclarationOnly' from config.

Open
#32,380 6 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Awaiting More Feedback Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Search Terms

  • TS5053
  • emitDeclarationOnly

Suggestion

Using "emitDeclarationOnly": true in your tsconfig.json prevents you to do typechecking only runs as running tsc --noEmit will throw the following error.

error TS5053: Option 'emitDeclarationOnly' cannot be specified with option 'noEmit'.

And the CLI does not look like to have any flag to bypass the error (eg. something like --noEmitDeclarationOnly).

I don't see a reason why a noEmit cli flag would not take precedence over the emitDeclarationOnly from the tsconfig.

Use Cases

With a project with a tsconfig.json set with emitDeclarationOnly and using another compiler like babel to produce the built javascript code, you want to be able to both:

  • Compile declaration files (running tsc)
  • Perform typechecking as a test stage (eg. travis) (running tsc --noEmit). Especially since you do not use TypeScript to compile (so a build could pass with typings errors).

Examples

https://github.com/mgcrea/node-influx-syslog

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the compiler-option validation that reports TS5053 and trace how command-line noEmit is merged with tsconfig emitDeclarationOnly. Add coverage for the requested precedence and verify both declaration emission and noEmit type-checking paths; done means tsc --noEmit accepts the configuration while normal tsc behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.