question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:5

github_iconTop GitHub Comments

10reactions
draperunnercommented, Nov 27, 2020

FYI, this works:

tsc --noEmit --emitDeclarationOnly false
1reaction
aryzingcommented, Jan 8, 2020

@SamB seems reasonable, although to retain the general idea that CLI flags generally override configured behavior, cli flags should always override code emit settings from config, and noEmit should only override emit requests at the same level

For example, the noEmit flag overrides other flags that request code be emitted, and noEmit key in config overrides other keys in config that request code to be emitted. However, flags requesting code to be emitted will override noEmit key in config.

Pseudo-code for logic:

if (noEmit_flag) {
  do not emit anything
} else if (noEmit_flag && emitSomething_flag) {
  do not emit anything
} else if (noEmit_key && emitSomething_flag) {
  emit what was requested, cli flags always override 
} else if (noEmit_key && emitSomething_key) {
  do not emit anything
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Option 'noEmit' cannot be specified with option 'incremental'
Allow noEmit and composite together in 3.7 #33809 ... So you should either remove noEmit: true or change it to emitDeclarationOnly: true ....
Read more >
noEmit - TSConfig Option
All the configuration options for a project. Classes. How to provide types to JavaScript ES6 classes. Made with ♥ in Redmond, Boston, SF...
Read more >
TypeScript With Babel: A Beautiful Marriage - I Am Turns
Let me show you. ... But the Babel configuration improves on this with ... "noEmit": true, // Enable strictest settings like ...
Read more >
A brief introduction to TypeScript's command-line interface ...
In this lesson, let's learn how to use the tsc command-line options ... we learn about different TypeScript compiler settings and the role ......
Read more >
Tsconfig noemit - Lokale Tafelrunde Oberhavel
The configuration from the base file are loaded first, then overridden by those ... { "noEmit": true } }env variable name description default;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found