microsoft / microsoft/TypeScript
Access `global` as a type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Since https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#augmenting-globalmodule-scope-from-modules it's been possible to augment the global from a module. However, in TypeScript definitions (such as dom.d.ts or node.d.ts) we're left to create our own "globals". This results in two issue:
- inconsistency with what is actually the global namespace
- requiring the declaration of global types multiple times in case it's used as a "real global" or from
window.(browsers) orglobal.(node)
Instead of this, it'd be really nice to access TypeScript's global as a type. For instance, in dom.d.ts we could do:
declare var window: global
Or in node.d.ts:
declare var global: global
I couldn't see any previous issues, but it's partially related to things like https://github.com/Microsoft/TypeScript/issues/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposal alongside dom.d.ts and node.d.ts, then read the related issue #12902 to distinguish this request from global-scope additions. Done means TypeScript provides a usable global namespace type so declarations such as window and global can reference it without duplicating global types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100