Closed
Description
TypeScript Version: 3.8.0-dev.20191026
Search Terms:
completions, discriminated unions
Code
const A = "A";
const B = "B";
interface AAction {
type: typeof A;
payload: {
a: string;
b: string;
}
}
interface BAction {
type: typeof B;
payload: {
c: string;
d: string;
}
}
interface ActionMap {
[A]: AAction;
[B]: BAction;
}
declare function test<K extends keyof ActionMap>(key: K, payload: ActionMap[K]["payload"]): void;
test("A", { /* completion here */ })
Expected behavior:
Should give only a
and b
. TS 3.6.3 (haven't tested on 3.6.4) works fine
Actual behavior:
Returns a, b, c, d