TypeScript Version: 2.3.4
Code
The browser Intersection Observer API defines these on the window:
window.IntersectionObserver
window.IntersectionObserverEntry
Expected behavior:
These should be defined in the DOM lib typings.
Actual behavior:
They are not defined, so I get type errors.
PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.
Can this issue be closed? Looks like the change has already been merged into master?
Aha, looks like they are in the typings, just not exposed on the window interface:
new IntersectionObserver(() => {}); // no error
window.IntersectionObserver // error: Property 'IntersectionObserver' does not exist on type 'Window'.
As a temporary fix
export {}
declare global {
interface Window {
IntersectionObserver: typeof IntersectionObserver
}
}
Most helpful comment
As a temporary fix