File: discriminantUsingEvaluatableTemplateExpression.types

package info (click to toggle)
node-typescript 5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 497,488 kB
  • sloc: javascript: 2,107,274; makefile: 6; sh: 1
file content (42 lines) | stat: -rw-r--r-- 993 bytes parent folder | download
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

  },
});