Description
TypeScript Version: 3.3.3 / 3.4.0-dev.20190209
Search Terms:
crash union intersection cannot read property flags undefined
Code
Unfortunately this came up during a big refactor so I don't have a small repro case, but the next
branch of trilogy reproduces it here:
git clone --single-branch --branch next https://github.com/citycide/trilogy.git
cd trilogy
npm install
./node_modules/.bin/tsc
I reproduced on both Windows 10 & Ubuntu, plus my Travis CI suite. Interestingly VS Code's TS server doesn't show any errors at all and keeps type checking like normal.
Based on the call stack we can probably assume it's due to a union or intersection type somewhere but I don't know how to trace it back effectively.
Expected behavior:
Compile without crashing.
Actual behavior:
> .\node_modules\.bin\tsc
E:\dev\trilogy\node_modules\typescript\lib\tsc.js:71784
throw e;
^
TypeError: Cannot read property 'flags' of undefined
at getRegularTypeOfLiteralType (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:33693:25)
at addTypesToIntersection (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:32901:69)
at getIntersectionType (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:32973:28)
at combineUnionParameters (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30815:38)
at combineSignaturesOfUnionMembers (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30833:26)
at E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30782:181
at Object.map (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:426:29)
at _loop_5 (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30782:144)
at getUnionSignatures (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30790:35)
at resolveUnionTypeMembers (E:\dev\trilogy\node_modules\typescript\lib\tsc.js:30857:34)
Playground Link:
Related Issues:
This error message is pretty common so there are a lot of issues referencing it, however they vary pretty wildly in the call stack: #28935, #27345, #25387, #25264, #15456, #19142, #2127