Open
Description
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)
Related Issues: