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
3.1rc (js) regression: writing to property of a global variable redefines entire variable type #27099
Run tsc --noEmit --allowJs --checkJs with @types/node available (see below for a non-node example).
Expected behavior:
No error.
Actual behavior: error TS2339: Property 'argv' does not exist on type 'typeof process'.
Not a problem in typescript code. When all the example lines are present, the definition and type definition of process now point to the process.env.ENV_VAR line instead of to @types/node.
To get the bug, either module.exports needs to be set or a file needs to be required or imported, so I assume it being a module is important. Writing to anything on process seems to trigger it, not just a sub-property (so e.g. process.env = {ENV_VAR: 'val'}; would also trigger the bug, though probably not a good idea in real code :).
// test.jswindow.name='name';window.console.log(5);// error TS2339: Property 'console' does not exist on type 'typeof window'.module.exports='anything';
It looks like issue #27057 may be the same issue, but I haven't cloned and run the project given in the example to verify.
changed the title [-]3.1rc (js) regression: writing to property of global `process` redefines entire 'process' type[/-][+]3.1rc (js) regression: writing to property of global object redefines entire object type[/+]on Sep 14, 2018
changed the title [-]3.1rc (js) regression: writing to property of global object redefines entire object type[/-][+]3.1rc (js) regression: writing to property of a global variable redefines entire variable type[/+]on Sep 14, 2018
Repros on 3.0 with an expando initializer, like window.name = {}. The bug is more visible now that initializers aren't required to be expandos. The core of the problem is in iniitalizeTypeChecker:
CommonJS modules should still merge with globals, because, in JS, the compiler allows undeclared identifiers to act as namespaces in exactly the way assignment to window works.
Activity
brendankenny commentedon Sep 14, 2018
bisecting leads to #26908.
It seems to occur for any globals, e.g.
It looks like issue #27057 may be the same issue, but I haven't cloned and run the project given in the example to verify.
[-]3.1rc (js) regression: writing to property of global `process` redefines entire 'process' type[/-][+]3.1rc (js) regression: writing to property of global object redefines entire object type[/+][-]3.1rc (js) regression: writing to property of global object redefines entire object type[/-][+]3.1rc (js) regression: writing to property of a global variable redefines entire variable type[/+]sandersn commentedon Sep 14, 2018
Repros on 3.0 with an expando initializer, like
window.name = {}. The bug is more visible now that initializers aren't required to be expandos. The core of the problem is in iniitalizeTypeChecker:CommonJS modules should still merge with globals, because, in JS, the compiler allows undeclared identifiers to act as namespaces in exactly the way assignment to
windowworks.Add a fix for #27099
Fix cross-file merge of assignment decl valueDeclaration (#26918)