Microsoft/TypeScript
GitHub ã§èŠãError when accessing properties on `globalThis` with the same name of a global variable
Open
#58,345 opened on 2024幎4æ28æ¥
BugDomain: Something ElseHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
globalThis redefined error script property does not exist
ð Version & Regression Information
- This is the behavior in every version I tried
⯠Playground Link
ð» Code
let invalid1 = globalThis.invalid1;
let y = globalThis.invalid1;
let z = globalThis.invalid2;
ð Actual behavior
Property 'invalid1' does not exist on type 'typeof globalThis'.
ð Expected behavior
It should either complain about both invalid1 and invalid2, or neither
Additional information about the issue
It only happens in scripts and not in modules (if I add export {}, there are no reported errors).