You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ambient external module name incorrectly appears in keyof typeof globalThisΒ #48147
// Module declaration ( should not concern globalThis ? )declare module "foo"{}typeglobalType=typeofglobalThistypeglobalKey=keyofglobalTypeglobalThis["foo"]// Property 'foo' does not exist on type 'typeof globalThis'.constf: globalKey="foo"// OK// See playground for more examples
π Actual behavior
"foo" is a valid key/property of typeof globalThis
π Expected behavior
"foo" should not be a valid key/property of typeof globalThis as globalThis["foo"] is not valid
It took me a long time to figure out, but it turns out that globalThis["\"foo\""] is also erroneously valid. keyof typeof globalThis flattens "\"foo\"" to "foo", which makes the bug more obvious.
Activity
[-]Incorrect globalThis type[/-][+]Ambient external module name incorrectly appears in `keyof typeof globalThis`[/+]sandersn commentedon May 3, 2022
It took me a long time to figure out, but it turns out that
globalThis["\"foo\""]is also erroneously valid.keyof typeof globalThisflattens"\"foo\""to"foo", which makes the bug more obvious.