Skip to content

Crash with Cannot read property 'flags' of undefined (union related?) #29884

Closed
@haltcase

Description

@haltcase

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:

  1. git clone --single-branch --branch next https://github.com/citycide/trilogy.git
  2. cd trilogy
  3. npm install
  4. ./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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions