deno_lint
deno_lint copied to clipboard
Support for global declarations
Note: This demonstration is a corner case and should be avoided by developers when possible. However since it's supported by TypeScript and in lack of a better solution it should be considered a "feature".
types.ts
declare global {
var x: number;
}
globalThis.x = 1;
export {};
mod.ts
import "./types.ts";
console.log(x); ///Outputs 1, there is no compilation error
TypeScript is ok with this, and since you are writing a property in globalThis
on import, JavaScript is as well. However deno lint will mark x
as undefined.