Closed
Description
🔎 Search Terms
"declare class" in a global is not visible in external files,
extending typescript global object with "declare class",
declared class in global not found,
typescript globals.d.ts declared global class not found
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about globals and declaration files here
⏯ Playground Link
https://github.com/jayshah123/typescript-declare-global-class-issue
💻 Code
// global.d.ts
export { };
declare global {
var myGlobalVariable: string;
class WorldClass {
constructor();
important: number;
}
}
// index.ts
const w = new global.WorldClass(); // Property 'WorldClass' does not exist on type 'typeof globalThis'.ts(2339)
\
const h = global.myGlobalVariable;
console.log(h);
🙁 Actual behavior
Class declared in global not allowed
🙂 Expected behavior
Class declared in global should be allowed.
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels