Skip to content
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

--noEmit hides 'declaration' related errors #37769

Closed
martaver opened this issue Apr 3, 2020 · 5 comments
Closed

--noEmit hides 'declaration' related errors #37769

martaver opened this issue Apr 3, 2020 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@martaver
Copy link

martaver commented Apr 3, 2020

TypeScript Version: 3.8.3

Search Terms:
noEmit, declaration

Code

export function test() {
  return class MyTestClass {
    private foo = 0;
  };
}

Expected behavior:
My tsconfig contains compilerOptions.declaration: true.

When I run tsc, the above code (correctly) emits compile time error:

Property 'foo' of exported class expression may not be private or protected.ts(4094)

I would expect running tsc with --noEmit would return the same errors, since all other configuration options are identical, we just want to skip producing our outputs. This is a common use case for tasks that watch for ts compile-time errors.

Actual behavior:

When I run it tsc with --noEmit, these errors are now hidden.

Practical impact of this is that I have vscode reporting errors inline that my project-wide error watcher does not pick up.

This causes me anxiety.

Playground Link:
N/A

Related Issues:
#30355

This case demonstrates that the error should be occurring whenever declaration: true... this leads me to believe that the error being hidden when noEmit: true is an unintended side effect.

@RyanCavanaugh
Copy link
Member

What part of your build pipeline is actually producing .d.ts files?

@sheetalkamat
Copy link
Member

noEmit means you are not emitting so providing errors from declaration emit seems incorrect?

@martaver
Copy link
Author

martaver commented Apr 3, 2020

@RyanCavanaugh Well ideally, all of the packages I build with tsc will emit js and .d.ts files. For distribution to npm.

@sheetalkamat I'm interpreting noEmit as a dry run... in my use case I just want to check my code for type errors with the same build configuration that I will use in the actual build.

@RyanCavanaugh RyanCavanaugh added the Question An issue which isn't directly actionable in code label Apr 13, 2020
@RyanCavanaugh
Copy link
Member

Declaration emit errors are produced as part of producing declaration files themselves; basically you only see declaration emit errors iff declaration files are being made. This is the intended behavior since some code is fine when it's not making a .d.ts but needs extra annotations or local aliases to make a valid .d.ts. We could take a separate suggestion for some mode to "act as if" we're generating these files, but there'd need to be some compelling scenario for it since this generally don't seem to be something people need.

@typescript-bot
Copy link
Collaborator

This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants