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
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 :).
The text was updated successfully, but these errors were encountered:
// 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.
brendankenny
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
Sep 14, 2018
brendankenny
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
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.
* Fix cross-file merge of assignment decl valueDeclaration
Previously mergeSymbol in the checker always updated valueDeclaration if
target.valueDeclaration was an assignment declaration. The binder only
updates target.valueDeclaration if it is an assignment declaration and
source.valueDeclaration is *not* an assignment declaration. Now the
checker behaves the same way as the binder.
* Update baselines
* Add a fix for #27099
Makes commonjs merge with globals when appropriate.
* Add a separate jsGlobalAugmentations table
Instead of trying to filter these augmentations out of the normal symbol
table of commonjs modules.
TypeScript Versions: 3.1.0-rc.20180911, 3.1.0-dev.20180914
Not an issue in 3.1.0-dev.20180831 (bisected to #26908)
Search Terms:
does not exist global write module
Code
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 theprocess.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 onprocess
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 :).The text was updated successfully, but these errors were encountered: