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

isolatedDeclarations not giving related errors under noEmit #59024

Closed
SuperchupuDev opened this issue Jun 25, 2024 · 6 comments Β· Fixed by #59065
Closed

isolatedDeclarations not giving related errors under noEmit #59024

SuperchupuDev opened this issue Jun 25, 2024 · 6 comments Β· Fixed by #59065
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@SuperchupuDev
Copy link

πŸ”Ž Search Terms

"isolated declarations", "isolated declarations noEmit"

πŸ•— Version & Regression Information

  • This changed in commit or PR e62418e (before that commit TS didn't recognize the option on tsconfig)

⏯ Playground Link

No response

πŸ’» Code

// must have a return type, should give error
function thingThatShouldErrorOnIsolatedDeclarations() {
  return 0;
}

πŸ™ Actual behavior

tsc --noEmit --isolatedDeclarations doesn't report any error, even though tsc --isolatedDeclarations does (vscode does too)

πŸ™‚ Expected behavior

tsc --noEmit --isolatedDeclarations reports the error, just like it does without the --noEmit flag

Additional information about the issue

tsconfig used:

{
  "compilerOptions": {
    "target": "es2022",
    "lib": ["esnext"],

    "module": "esnext",
    "moduleResolution": "bundler",

    "outDir": "dist",
    "esModuleInterop": true,
    "verbatimModuleSyntax": true,

    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "noEmitOnError": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "declaration": true,

    "strict": true
  }
}
@jakebailey
Copy link
Member

Debugging, handleNoEmitOptions skips getting declaration diagnostics when noEmit is set. The editor is different and always grabs declaration errors.

Disabling the noEmit skip there fixes the issue, but then has weird knock-on effects. I haven't been able to solve. My test has been pushed to https://github.com/jakebailey/TypeScript/tree/fix-59024 (it doesn't work in a regular compiler test since we always emit).

@sheetalkamat Do you have any ideas as to how to fix this?

@sheetalkamat
Copy link
Member

Will take a look.

@sheetalkamat
Copy link
Member

This is not a regression. We never reported declaration diagnostics under --noEmit through tsc
If we are changing this it will be need to be not a patch.

@jakebailey
Copy link
Member

Not a regression, no, but I feel like we need to do something here because we're offering up these diagnostics in the editor regardless of noEmit, but then you can get a passing result at the CLI or similar which seems really, really weird?

@sheetalkamat
Copy link
Member

sheetalkamat commented Jun 26, 2024

These diagnostics are offered when "emitting". Eg if you ran this code with "--noCheck" you will get that error. So its just where the error gets reported. It was modeled so that we are not doing extra pass .. so dts diagnostics are always reported when emitting dts file. (only excpetion is noEmitOnError)

Reference: https://github.com/microsoft/TypeScript/blob/main/tests/baselines/reference/tsc/noCheck/multiFile/dts-errors.js#L35

@RyanCavanaugh
Copy link
Member

Specifying isolatedDeclarations: true only makes sense if you want the errors (that's all the flag does, after all), so we should be evaluating them here. It's the same as specifying verbatimModuleSyntax and noEmit - the latter doesn't affect whether or not the former should do its checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
5 participants