-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Access global as a type #14052
Copy link
Copy link
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Since https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#augmenting-globalmodule-scope-from-modules it's been possible to augment the
globalfrom a module. However, in TypeScript definitions (such asdom.d.tsornode.d.ts) we're left to create our own "globals". This results in two issue:window.(browsers) orglobal.(node)Instead of this, it'd be really nice to access TypeScript's
globalas a type. For instance, indom.d.tswe could do:Or in
node.d.ts:I couldn't see any previous issues, but it's partially related to things like #12902 - the difference though is that those issues seems to be tracking adding variables to the TypeScript global scope whereas this would be using the global scope as a type to define these variables themselves.