Description
Bug Report
π Search Terms
π Version & Regression Information
- This is a crash
- This changed between versions 4.0.5 and 4.1.3
β― Playground Link
π» Code
exports.fn1();
exports.fn2 = Math.min;
π Actual behavior
Crashing:
TypeError: Cannot read property 'length' of undefined
at getPropertyOfType (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:44083:45)
at getTypeOfDottedName (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:52423:44)
at getEffectsSignature (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:52436:32)
at getTypeAtFlowCall (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:52755:33)
at getTypeAtFlowNode (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:52636:32)
at getFlowTypeOfReference (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:52593:51)
at checkIdentifier (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:53580:28)
at checkExpressionWorker (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:59973:28)
at checkExpression (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:59928:38)
at checkNonNullExpression (C:\Users\mihai\danfo\node_modules\typescript\lib\tsc.js:55612:37)
This is running tsc.js
with: node --inspect-brk node_modules\typescript\lib\tsc.js repor.js --out repor.out.js --allowJs
and some state in context:
π Expected behavior
Transpile, don't crash. Can produce errors/warnings, but not crash.
Background
This happened when I tried to run TypeScript over the latest CodeMirror, and stumbled upon the file runmode.node.js (see on unpkg). Then, simplified to the minimal reproduction case.
As you can see from the caught error above, resolved.callSignatures
is undefined
and that causes throw here.
I assume this happens because exports
isn't treated as a normal global variable even in a variable position. But in variable position it should be treated as a variable.
Note: can't simplify any more, both lines are necessary. Which means it's not just bad handling of exports
, but something more conspiratorial.