File: circularIndexedAccessErrors.types

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (69 lines) | stat: -rw-r--r-- 893 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
=== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts ===
type T1 = {
>T1 : T1

    x: T1["x"];  // Error
>x : any

};

type T2<K extends "x" | "y"> = {
>T2 : T2<K>

    x: T2<K>[K];  // Error
>x : T2<K>[K]

    y: number;
>y : number
}

declare let x2: T2<"x">;
>x2 : T2<"x">

let x2x = x2.x;
>x2x : any
>x2.x : any
>x2 : T2<"x">
>x : any

interface T3<T extends T3<T>> {
    x: T["x"];
>x : T["x"]
}

interface T4<T extends T4<T>> {
    x: T4<T>["x"];  // Error
>x : any
}

class C1 {
>C1 : C1

    x: C1["x"];  // Error
>x : any
}

class C2 {
>C2 : C2

    x: this["y"];
>x : this["y"]

    y: this["z"];
>y : this["z"]

    z: this["x"];
>z : this["x"]
}

// Repro from #12627

interface Foo {
    hello: boolean;
>hello : boolean
}

function foo<T extends Foo | T["hello"]>() {
>foo : <T>() => void
}