Skip to content

noEmit should be allowed with outDir #7397

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

Closed
anilanar opened this issue Mar 5, 2016 · 8 comments
Closed

noEmit should be allowed with outDir #7397

anilanar opened this issue Mar 5, 2016 · 8 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@anilanar
Copy link
Contributor

anilanar commented Mar 5, 2016

And possibly with other out variations. Ideally, noEmit should have priority over output related options.

Reasoning: I have a syntax checking script that should not actually write files. My build script relies on tsconfig.json which has outDir compiler option set.

Syntax check command:

> tsc --noEmit 2>&1 | pipe_it_somewhere_for_syntax_checking

Build command:

> tsc

tsconfig.json

{
   ...
   "outDir": "build/"
   ...
}

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

@mhegazy
Copy link
Contributor

mhegazy commented Mar 5, 2016

Have you considered using noEmitOnError?

@anilanar
Copy link
Contributor Author

anilanar commented Mar 5, 2016

Yes. I don't want syntax checker to write files whether there are errors or not.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 5, 2016

I don't want syntax checker to write files whether there are errors or not.

I am not sure i understood this statement. what is the "syntax checker" here? and who is writing the files? is it tsc? or some other tool? when do you want them to be written? and when not?

@anilanar
Copy link
Contributor Author

anilanar commented Mar 5, 2016

Let's assume I'm the syntax checker, I'm the builder and there are no tools involved.

To compile, I just run tsc. It's done based on my config in tsconfig.json.

In addition, I want to see if there are any errors or not, without writing anything to the disk. So I run tsc --noEmit. It complains about outDir and noEmit not working together.

Obviously there are workarounds for this simple example. I can omit outDir from tsconfig.json, run tsc --outDir 'path' to compile and run tsc --noEmit to syntax check.

It feels intuitively better for noEmit to override output related compiler options instead of returning an error.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 5, 2016

I do not disagree with the original suggestion; I am just wondering why run the compiler twice on the same set of sources?

@kylecordes
Copy link

@mhegazy I can't answer for the others, but for me this is because I might want to check from the command line that everything is good, but I in fact never use the output I create by running tsc; the actual work happens from (for example in some projects) webpack. if I'm running a commandline check that all is well, there's no point in admitting output in any case, because it's going to get ignored anyway and recompiled when webpack run the TS compiler. You might wonder, why ever bother to compile from the command line, since I'm using a different tool to run the compiler for actual output anyway? Probably the same answer as Anil: for a reason, I occasionally want to check from the command line that I have a clean compile.

@anilanar
Copy link
Contributor Author

anilanar commented Mar 5, 2016

Another use case is for vim-syntastic. It's a linter tool for vim and supports multiple languages. It uses tsc for typescript by default. It's not supposed to compile and write files so it currently uses noEmit option. It breaks if there's a tsconfig.json with out* options.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 5, 2016

Thanks for the details. PRs are welcomed. The change will be to remove the error check, do not think anything else is required.

@mhegazy mhegazy added Bug A bug in TypeScript Help Wanted You can do this labels Mar 5, 2016
@mhegazy mhegazy added this to the Community milestone Mar 5, 2016
anilanar added a commit to anilanar/TypeScript that referenced this issue Mar 6, 2016
anilanar added a commit to anilanar/TypeScript that referenced this issue Mar 12, 2016
mhegazy added a commit that referenced this issue Mar 12, 2016
Fix #7397: Remove error checks for noEmit and out* compiler options combined.
@mhegazy mhegazy modified the milestones: TypeScript 2.0, Community Mar 12, 2016
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Mar 12, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants