File: contextualTypeOfIndexedAccessParameter.types

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (45 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (3)
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
43
44
45
=== tests/cases/compiler/contextualTypeOfIndexedAccessParameter.ts ===
type Keys = "a" | "b";
>Keys : "a" | "b"

type OptionsForKey = { a: { cb: (p: number) => number } } & { b: {} };
>OptionsForKey : { a: { cb: (p: number) => number; }; } & { b: {}; }
>a : { cb: (p: number) => number; }
>cb : (p: number) => number
>p : number
>b : {}

declare function f<K extends Keys>(key: K, options: OptionsForKey[K]): void;
>f : <K extends Keys>(key: K, options: OptionsForKey[K]) => void
>key : K
>options : OptionsForKey[K]

f("a", {
>f("a", {    cb: p => p,}) : void
>f : <K extends Keys>(key: K, options: OptionsForKey[K]) => void
>"a" : "a"
>{    cb: p => p,} : { cb: (p: number) => number; }

    cb: p => p,
>cb : (p: number) => number
>p => p : (p: number) => number
>p : number
>p : number

});

function g<
>g : <K extends "a" | "b">(x: ({    a: string;} & {    b: string;})[K], y: string) => void

    K extends "a" | "b">(x: ({ a: string } & { b: string })[K], y: string) {
>x : ({ a: string; } & { b: string; })[K]
>a : string
>b : string
>y : string

    x = y;
>x = y : string
>x : ({ a: string; } & { b: string; })[K]
>y : string
}