TypeScript Version: 3.5.3, 3.6.3
Search Terms:
- triple slash lib dom
- triple slash global
Code
arbitrary.d.ts
/// <reference lib="dom" />index.ts
export let x: Element;
Expected behavior:
Executing npx tsc --noEmit --target esnext --lib esnext index.ts should produce a compile error because Element is not defined nor imported and lib dom is not set globally.
The documentation for triple slash directives states the following:
https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html
For declaration file authors who rely on built-in types, e.g. DOM APIs or built-in JS run-time constructors like Symbol or Iterable, triple-slash-reference lib directives are recommended. Previously these .d.ts files had to add forward/duplicate declarations of such types.
used in e.g. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/superagent/index.d.ts
Actual behavior:
It just compiles.
Related Issues:
- Placeholder Type Declarations #31894
- Don't let the declaration file break compilation #32908 (adding skipLibChecks does not solve this problem, and should not be the right solution)