|
| 1 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(2,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation. |
| 2 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(6,5): error TS2502: 'e' is referenced directly or indirectly in its own type annotation. |
| 3 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(10,5): error TS2502: 'f' is referenced directly or indirectly in its own type annotation. |
| 4 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(12,5): error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. |
| 5 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(14,5): error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. |
| 6 | +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(51,5): error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. |
| 7 | + |
| 8 | + |
| 9 | +==== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts (6 errors) ==== |
| 10 | + // The following are errors because of circular references |
| 11 | + var c: typeof c; |
| 12 | + ~ |
| 13 | +!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation. |
| 14 | + var c: any; |
| 15 | + var d: typeof e; |
| 16 | + var d: any; |
| 17 | + var e: typeof d; |
| 18 | + ~ |
| 19 | +!!! error TS2502: 'e' is referenced directly or indirectly in its own type annotation. |
| 20 | + var e: any; |
| 21 | + |
| 22 | + interface Foo<T> { } |
| 23 | + var f: Array<typeof f>; |
| 24 | + ~ |
| 25 | +!!! error TS2502: 'f' is referenced directly or indirectly in its own type annotation. |
| 26 | + var f: any; |
| 27 | + var f2: Foo<typeof f2>; |
| 28 | + ~~ |
| 29 | +!!! error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. |
| 30 | + var f2: any; |
| 31 | + var f3: Foo<typeof f3>[]; |
| 32 | + ~~ |
| 33 | +!!! error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. |
| 34 | + var f3: any; |
| 35 | + |
| 36 | + // None of these declarations should have any errors! |
| 37 | + // Truly recursive types |
| 38 | + var g: { x: typeof g; }; |
| 39 | + var g: typeof g.x; |
| 40 | + var h: () => typeof h; |
| 41 | + var h = h(); |
| 42 | + var i: (x: typeof i) => typeof x; |
| 43 | + var i = i(i); |
| 44 | + var j: <T extends typeof j>(x: T) => T; |
| 45 | + var j = j(j); |
| 46 | + |
| 47 | + // Same as h, i, j with construct signatures |
| 48 | + var h2: new () => typeof h2; |
| 49 | + var h2 = new h2(); |
| 50 | + var i2: new (x: typeof i2) => typeof x; |
| 51 | + var i2 = new i2(i2); |
| 52 | + var j2: new <T extends typeof j2>(x: T) => T; |
| 53 | + var j2 = new j2(j2); |
| 54 | + |
| 55 | + // Indexers |
| 56 | + var k: { [n: number]: typeof k;[s: string]: typeof k }; |
| 57 | + var k = k[0]; |
| 58 | + var k = k['']; |
| 59 | + |
| 60 | + // Hybrid - contains type literals as well as type arguments |
| 61 | + // These two are recursive |
| 62 | + var hy1: { x: typeof hy1 }[]; |
| 63 | + var hy1 = hy1[0].x; |
| 64 | + var hy2: { x: Array<typeof hy2> }; |
| 65 | + var hy2 = hy2.x[0]; |
| 66 | + |
| 67 | + interface Foo2<T, U> { } |
| 68 | + |
| 69 | + // This one should be an error because the first type argument is not contained inside a type literal |
| 70 | + var hy3: Foo2<typeof hy3, { x: typeof hy3 }>; |
| 71 | + ~~~ |
| 72 | +!!! error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. |
| 73 | + var hy3: any; |
0 commit comments