Skip to content

Construction of union type causes TypeError: Cannot read property 'flags' of undefined #20802

@SeeSpring

Description

@SeeSpring

TypeScript Version: 2.6.2

Code

function x<T>(ctor: {
    (this: {}, v: T): void;
    new(v: T): void;
} | {
    (v: T): void;
    new(v: T): void;
},t:T) {
    new ctor(T)
};

Expected behavior:
Code compiles
Actual behavior:

tsc test.ts 
/usr/lib/node_modules/typescript/lib/tsc.js:59636
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at Object.getCheckFlags (/usr/lib/node_modules/typescript/lib/tsc.js:8713:23)
    at getTypeOfSymbol (/usr/lib/node_modules/typescript/lib/tsc.js:23412:20)
    at /usr/lib/node_modules/typescript/lib/tsc.js:24230:113
    at Object.map (/usr/lib/node_modules/typescript/lib/tsc.js:493:29)
    at getUnionSignatures (/usr/lib/node_modules/typescript/lib/tsc.js:24230:68)
    at resolveUnionTypeMembers (/usr/lib/node_modules/typescript/lib/tsc.js:24259:34)
    at resolveStructuredTypeMembers (/usr/lib/node_modules/typescript/lib/tsc.js:24481:21)
    at getSignaturesOfStructuredType (/usr/lib/node_modules/typescript/lib/tsc.js:24779:32)
    at getSignaturesOfType (/usr/lib/node_modules/typescript/lib/tsc.js:24785:20)
    at resolveNewExpression (/usr/lib/node_modules/typescript/lib/tsc.js:32995:39)

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions