Skip to content

Incremental builds ignore missing ambient declarations #36728

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
fgallardograzio opened this issue Feb 11, 2020 · 0 comments · Fixed by #37538
Closed

Incremental builds ignore missing ambient declarations #36728

fgallardograzio opened this issue Feb 11, 2020 · 0 comments · Fixed by #37538
Assignees
Labels
Bug A bug in TypeScript Domain: --incremental The issue relates to incremental compilation Fix Available A PR has been opened for this issue

Comments

@fgallardograzio
Copy link

TypeScript Version: 3.8.0-dev.20200208

Search Terms: incremental build ambient declarations declare global dts

Code

// globals.d.ts
declare namespace Config {
  const value: string;
}
// index.ts
console.log(Config.value);
// tsconfig.json
{
  "compilerOptions": {
    "incremental": true
  }
}

Steps to reproduce:

  • Run tsc. The project should be built successfully.
  • Remove the contents of globals.d.ts or delete the file itself. (vscode immediately reports the "Cannot find name 'Config'." error in index.ts).
  • Run tsc again. The build process still completes successfully.
  • Run tsc --incremental false. Now it fails correctly.

Expected behavior:
The removal of an ambient declaration should be caught by TS when using --incremental or --build and the proper error should be reported.

Actual behavior:
When a complete ambient type declaration is removed, related types don't seem to be re-checked.

On the other hand, changing an ambient declaration works as expected.
If, e.g., the value constant is removed from the namespace declaration, the proper error is thrown.

// globals.d.ts
declare namespace Config {
//   const value: string;
}

Please note that this also affects project references' --builds.

Playground Link:
Not needed.

Related Issues:
Not an issue, but maybe #32849 is related?

Thanks

@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: --incremental The issue relates to incremental compilation labels Feb 11, 2020
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.9.0 milestone Feb 11, 2020
@sheetalkamat sheetalkamat added the Fix Available A PR has been opened for this issue label Mar 23, 2020
sheetalkamat added a commit that referenced this issue Mar 25, 2020
* Add test case when the errors are not refreshed if global file is deleted
Testcase for #36728

* When the global file is deleted mark all files as changed
Fixes #36728

* Update other baselines to fix file info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: --incremental The issue relates to incremental compilation Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants