Open mgcrea opened 5 years ago
Hmm. What could go wrong? The worst I can think of is if someone passes --emitDeclarationOnly
on the command line when they already have "noEmit": true
in tsconfig.json
, if they already had declaration
or composite
set for some reason, then the simplest implementation approach would probably still end up emitting nothing ...
+1
+1
@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
}
FYI, this works:
tsc --noEmit --emitDeclarationOnly false
Why is this issue stale? I think that the request is a valid one, and many other plugins do the same. I am seconding @aryzing s comment, that cli flags should overwrite configuration flags, so that if I generally want to emit only declarations when compiling with typescript, I add that to the config, and otherwise, I run tsc
with the --noEmit
flag, when I am only typechecking.
Until that, @draperunner s workaround is okay, but I think that if cli parameters do not take precedence over the config parameters, this could lead to other strange bugs, which won't be as easily solvable as this one.
Search Terms
Suggestion
Using
"emitDeclarationOnly": true
in yourtsconfig.json
prevents you to do typechecking only runs as runningtsc --noEmit
will throw the following error.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 theemitDeclarationOnly
from the tsconfig.Use Cases
With a project with a
tsconfig.json
set withemitDeclarationOnly
and using another compiler like babel to produce the built javascript code, you want to be able to both:tsc
)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: