i'm facing an issue where I can't properly extend globalThis. this is basically the setup that I have...
src/globals.d.ts:
export {};
interface Foo {
x: number;
}
declare global {
let foo: Foo;
// uncomment bottom and comment top to fix the error
// var foo: Foo;
}
src/index.ts:
globalThis.foo = {
x: 1
};
console.log(globalThis.foo);
the compile errors on both globalThis.foo accesses. strangely, if i change the let in globals.d.ts to var, it passes. what am i missing?
here's a codesandbox showing the issue: https://codesandbox.io/s/typescript-forked-hm6knw?file=/src/index.ts:0-59