Skip to content

Crash involving union of function types #31485

Closed
@tomblind

Description

@tomblind

TypeScript Version: 3.5.0-dev.20190518

Search Terms:
Cannot read property 'flags' of undefined
createSymbolWithType

Code

interface A {
    (this: void, a: string, b: number, c?: string): void;
    (this: void, b: number, c?: string): void;
}
interface B {
    (i: number): number;
}
declare const fn: A | B;
fn(0);

Expected behavior:
Should not crash.

Actual behavior:
tsc crashes with the following output:

node_modules\typescript\lib\tsc.js:72973
                throw e;
                ^

TypeError: Cannot read property 'flags' of undefined
    at createSymbolWithType (node_modules\typescript\lib\tsc.js:36787:46)
    at getUnionSignatures (node_modules\typescript\lib\tsc.js:30929:53)
    at resolveUnionTypeMembers (node_modules\typescript\lib\tsc.js:31021:34)
    at resolveStructuredTypeMembers (node_modules\typescript\lib\tsc.js:31330:21)
    at getSignaturesOfStructuredType (node_modules\typescript\lib\tsc.js:31782:32)
    at getSignaturesOfType (node_modules\typescript\lib\tsc.js:31788:20)
    at resolveCallExpression (node_modules\typescript\lib\tsc.js:42223:34)
    at resolveSignature (node_modules\typescript\lib\tsc.js:42494:28)
    at getResolvedSignature (node_modules\typescript\lib\tsc.js:42514:26)
    at checkCallExpression (node_modules\typescript\lib\tsc.js:42585:29)

Playground Link:

Related Issues:
#29884 may be related, as there's an example with a similar callstack, but it's closed as fixed already.

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