Skip to content

getSignaturesOfType throws Cannot read property 'flags' of undefined #33829

Open
@ark120202

Description

@ark120202

TypeScript Version: 3.7.0-dev.20191005

Search Terms: conditional, infer, mapped

Code

declare interface Foo {
    a(): boolean;
    b(): void;
    c(argument: boolean): void;
    d(argument: number): void;
}

declare const Foo: Mapped<Foo>;
type Mapped<T> = {
  [K in keyof T]: T[K] extends (...args: infer Args) => infer R
    ? (...args: Args) => R
    : never;
};

function foo(key: 'a' | 'b' | 'c' | 'd') {
  Foo[key]();
}

Note: removing any infer declaration or method from Foo makes it valid.

Expected behavior:

No errors

Actual behavior:

TypeError: Cannot read property 'flags' of undefined
    at Object.getCheckFlags (typescript/lib/tsc.js:10461:23)
    at getTypeOfSymbol (typescript/lib/tsc.js:32706:20)
    at getParameterCount (typescript/lib/tsc.js:46831:32)
    at combineUnionParameters (typescript/lib/tsc.js:33697:29)
    at combineSignaturesOfUnionMembers (typescript/lib/tsc.js:33730:26)
    at typescript/lib/tsc.js:33673:181
    at Object.map (typescript/lib/tsc.js:446:29)
    at _loop_7 (typescript/lib/tsc.js:33673:144)
    at getUnionSignatures (typescript/lib/tsc.js:33681:35)
    at resolveUnionTypeMembers (typescript/lib/tsc.js:33754:34)
    at resolveStructuredTypeMembers (typescript/lib/tsc.js:34078:21)
    at getSignaturesOfStructuredType (typescript/lib/tsc.js:34573:32)
    at getSignaturesOfType (typescript/lib/tsc.js:34579:20)

Playground Link: https://www.typescriptlang.org/play/?ts=3.7-Beta&ssl=1&ssc=1&pln=18&pc=2#code/CYUwxgNghgTiAEBLAdgFxDAZlMCBiA9gfAN4CwAUPNfFABQCUAXPAEZEQhTIDclNbRiwBuBRMD5UaYOrADmAVwC2INC3YFO3ZvFHjJA4LJiKVa+MmWsMOvRMoBfSpVCRYCMAWQBnVPEIELACyUAAOoSDAADwBAHySqACeEfAh4ZFRACqx8AC8pPzwANoA0kjI8ADWIIkEmPCZALosmaWN8CAAHujIwN7wdAB0w-LeLCiYGPAAgibeDHk5E1MASoXUAPwDw4OjLLNy84vwa1LULMggwhiSDpKUmArIYKiIXvCYRHTViSwA5FA-vAAD7wP6sIGgv5gSFg4B-BbkKQBIo-RqMW5AA

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions