Closed
Description
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 inindex.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' --build
s.
Playground Link:
Not needed.
Related Issues:
Not an issue, but maybe #32849 is related?
Thanks