1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
//// [tests/cases/compiler/discriminantUsingEvaluatableTemplateExpression.ts] ////
=== discriminantUsingEvaluatableTemplateExpression.ts ===
// repro from https://github.com/microsoft/TypeScript/issues/53888
type S = { d: "s"; cb: (x: string) => void };
>S : { d: "s"; cb: (x: string) => void; }
>d : "s"
>cb : (x: string) => void
>x : string
type N = { d: "n"; cb: (x: number) => void };
>N : { d: "n"; cb: (x: number) => void; }
>d : "n"
>cb : (x: number) => void
>x : number
declare function foo(foo: S | N): void;
>foo : (foo: S | N) => void
>foo : S | N
foo({
>foo({ d: `${"s"}`, cb: (x) => { x; // string },}) : void
>foo : (foo: S | N) => void
>{ d: `${"s"}`, cb: (x) => { x; // string },} : { d: "s"; cb: (x: string) => void; }
d: `${"s"}`,
>d : "s"
>`${"s"}` : "s"
>"s" : "s"
cb: (x) => {
>cb : (x: string) => void
>(x) => { x; // string } : (x: string) => void
>x : string
x; // string
>x : string
},
});
|