diff --git a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt index 18292c635e6..deb7fc137b2 100644 --- a/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt +++ b/tests/baselines/reference/implicitAnyFromCircularInference.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. -tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. -tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(3,5): error TS2502: 'a' is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(7,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation. +tests/cases/compiler/implicitAnyFromCircularInference.ts(10,5): error TS2502: 'd' is referenced directly or indirectly in its own type annotation. tests/cases/compiler/implicitAnyFromCircularInference.ts(15,10): error TS7023: 'g' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(18,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. tests/cases/compiler/implicitAnyFromCircularInference.ts(23,10): error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions. @@ -14,18 +14,18 @@ tests/cases/compiler/implicitAnyFromCircularInference.ts(46,5): error TS7023: 'x // Error expected var a: typeof a; ~ -!!! error TS7021: 'a' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'a' is referenced directly or indirectly in its own type annotation. // Error expected on b or c var b: typeof c; var c: typeof b; ~ -!!! error TS7021: 'c' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation. // Error expected var d: Array; ~ -!!! error TS7021: 'd' implicitly has type 'any' because it is referenced directly or indirectly in its own type annotation. +!!! error TS2502: 'd' is referenced directly or indirectly in its own type annotation. function f() { return f; } diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt b/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt new file mode 100644 index 00000000000..77bb58bfe0a --- /dev/null +++ b/tests/baselines/reference/recursiveTypesWithTypeof.errors.txt @@ -0,0 +1,73 @@ +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(2,5): error TS2502: 'c' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(6,5): error TS2502: 'e' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(10,5): error TS2502: 'f' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(12,5): error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(14,5): error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts(51,5): error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. + + +==== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts (6 errors) ==== + // The following are errors because of circular references + var c: typeof c; + ~ +!!! error TS2502: 'c' is referenced directly or indirectly in its own type annotation. + var c: any; + var d: typeof e; + var d: any; + var e: typeof d; + ~ +!!! error TS2502: 'e' is referenced directly or indirectly in its own type annotation. + var e: any; + + interface Foo { } + var f: Array; + ~ +!!! error TS2502: 'f' is referenced directly or indirectly in its own type annotation. + var f: any; + var f2: Foo; + ~~ +!!! error TS2502: 'f2' is referenced directly or indirectly in its own type annotation. + var f2: any; + var f3: Foo[]; + ~~ +!!! error TS2502: 'f3' is referenced directly or indirectly in its own type annotation. + var f3: any; + + // None of these declarations should have any errors! + // Truly recursive types + var g: { x: typeof g; }; + var g: typeof g.x; + var h: () => typeof h; + var h = h(); + var i: (x: typeof i) => typeof x; + var i = i(i); + var j: (x: T) => T; + var j = j(j); + + // Same as h, i, j with construct signatures + var h2: new () => typeof h2; + var h2 = new h2(); + var i2: new (x: typeof i2) => typeof x; + var i2 = new i2(i2); + var j2: new (x: T) => T; + var j2 = new j2(j2); + + // Indexers + var k: { [n: number]: typeof k;[s: string]: typeof k }; + var k = k[0]; + var k = k['']; + + // Hybrid - contains type literals as well as type arguments + // These two are recursive + var hy1: { x: typeof hy1 }[]; + var hy1 = hy1[0].x; + var hy2: { x: Array }; + var hy2 = hy2.x[0]; + + interface Foo2 { } + + // This one should be an error because the first type argument is not contained inside a type literal + var hy3: Foo2; + ~~~ +!!! error TS2502: 'hy3' is referenced directly or indirectly in its own type annotation. + var hy3: any; \ No newline at end of file diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.js b/tests/baselines/reference/recursiveTypesWithTypeof.js index 36c13405b0b..9fffd5b2604 100644 --- a/tests/baselines/reference/recursiveTypesWithTypeof.js +++ b/tests/baselines/reference/recursiveTypesWithTypeof.js @@ -1,6 +1,5 @@ //// [recursiveTypesWithTypeof.ts] -// None of these declarations should have any errors! -// Using typeof directly, these should be any +// The following are errors because of circular references var c: typeof c; var c: any; var d: typeof e; @@ -8,7 +7,6 @@ var d: any; var e: typeof d; var e: any; -// In type arguments, these should be any interface Foo { } var f: Array; var f: any; @@ -17,6 +15,7 @@ var f2: any; var f3: Foo[]; var f3: any; +// None of these declarations should have any errors! // Truly recursive types var g: { x: typeof g; }; var g: typeof g.x; @@ -49,25 +48,25 @@ var hy2 = hy2.x[0]; interface Foo2 { } -// This one should be any because the first type argument is not contained inside a type literal +// This one should be an error because the first type argument is not contained inside a type literal var hy3: Foo2; var hy3: any; //// [recursiveTypesWithTypeof.js] +// The following are errors because of circular references +var c; +var c; +var d; +var d; +var e; +var e; +var f; +var f; +var f2; +var f2; +var f3; +var f3; // None of these declarations should have any errors! -// Using typeof directly, these should be any -var c; -var c; -var d; -var d; -var e; -var e; -var f; -var f; -var f2; -var f2; -var f3; -var f3; // Truly recursive types var g; var g; @@ -94,6 +93,6 @@ var hy1; var hy1 = hy1[0].x; var hy2; var hy2 = hy2.x[0]; -// This one should be any because the first type argument is not contained inside a type literal +// This one should be an error because the first type argument is not contained inside a type literal var hy3; var hy3; diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.symbols b/tests/baselines/reference/recursiveTypesWithTypeof.symbols deleted file mode 100644 index ae1a311bdf6..00000000000 --- a/tests/baselines/reference/recursiveTypesWithTypeof.symbols +++ /dev/null @@ -1,187 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts === -// None of these declarations should have any errors! -// Using typeof directly, these should be any -var c: typeof c; ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) - -var c: any; ->c : Symbol(c, Decl(recursiveTypesWithTypeof.ts, 2, 3), Decl(recursiveTypesWithTypeof.ts, 3, 3)) - -var d: typeof e; ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) - -var d: any; ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) - -var e: typeof d; ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) ->d : Symbol(d, Decl(recursiveTypesWithTypeof.ts, 4, 3), Decl(recursiveTypesWithTypeof.ts, 5, 3)) - -var e: any; ->e : Symbol(e, Decl(recursiveTypesWithTypeof.ts, 6, 3), Decl(recursiveTypesWithTypeof.ts, 7, 3)) - -// In type arguments, these should be any -interface Foo { } ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 10, 14)) - -var f: Array; ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) - -var f: any; ->f : Symbol(f, Decl(recursiveTypesWithTypeof.ts, 11, 3), Decl(recursiveTypesWithTypeof.ts, 12, 3)) - -var f2: Foo; ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) - -var f2: any; ->f2 : Symbol(f2, Decl(recursiveTypesWithTypeof.ts, 13, 3), Decl(recursiveTypesWithTypeof.ts, 14, 3)) - -var f3: Foo[]; ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) ->Foo : Symbol(Foo, Decl(recursiveTypesWithTypeof.ts, 7, 11)) ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) - -var f3: any; ->f3 : Symbol(f3, Decl(recursiveTypesWithTypeof.ts, 15, 3), Decl(recursiveTypesWithTypeof.ts, 16, 3)) - -// Truly recursive types -var g: { x: typeof g; }; ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) - -var g: typeof g.x; ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->g.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) ->g : Symbol(g, Decl(recursiveTypesWithTypeof.ts, 19, 3), Decl(recursiveTypesWithTypeof.ts, 20, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 19, 8)) - -var h: () => typeof h; ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) - -var h = h(); ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) ->h : Symbol(h, Decl(recursiveTypesWithTypeof.ts, 21, 3), Decl(recursiveTypesWithTypeof.ts, 22, 3)) - -var i: (x: typeof i) => typeof x; ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 23, 8)) - -var i = i(i); ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) ->i : Symbol(i, Decl(recursiveTypesWithTypeof.ts, 23, 3), Decl(recursiveTypesWithTypeof.ts, 24, 3)) - -var j: (x: T) => T; ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 25, 28)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 25, 8)) - -var j = j(j); ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) ->j : Symbol(j, Decl(recursiveTypesWithTypeof.ts, 25, 3), Decl(recursiveTypesWithTypeof.ts, 26, 3)) - -// Same as h, i, j with construct signatures -var h2: new () => typeof h2; ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) - -var h2 = new h2(); ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) ->h2 : Symbol(h2, Decl(recursiveTypesWithTypeof.ts, 29, 3), Decl(recursiveTypesWithTypeof.ts, 30, 3)) - -var i2: new (x: typeof i2) => typeof x; ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 31, 13)) - -var i2 = new i2(i2); ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) ->i2 : Symbol(i2, Decl(recursiveTypesWithTypeof.ts, 31, 3), Decl(recursiveTypesWithTypeof.ts, 32, 3)) - -var j2: new (x: T) => T; ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 33, 34)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 33, 13)) - -var j2 = new j2(j2); ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) ->j2 : Symbol(j2, Decl(recursiveTypesWithTypeof.ts, 33, 3), Decl(recursiveTypesWithTypeof.ts, 34, 3)) - -// Indexers -var k: { [n: number]: typeof k;[s: string]: typeof k }; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->n : Symbol(n, Decl(recursiveTypesWithTypeof.ts, 37, 10)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->s : Symbol(s, Decl(recursiveTypesWithTypeof.ts, 37, 32)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -var k = k[0]; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -var k = k['']; ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) ->k : Symbol(k, Decl(recursiveTypesWithTypeof.ts, 37, 3), Decl(recursiveTypesWithTypeof.ts, 38, 3), Decl(recursiveTypesWithTypeof.ts, 39, 3)) - -// Hybrid - contains type literals as well as type arguments -// These two are recursive -var hy1: { x: typeof hy1 }[]; ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) - -var hy1 = hy1[0].x; ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->hy1[0].x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) ->hy1 : Symbol(hy1, Decl(recursiveTypesWithTypeof.ts, 43, 3), Decl(recursiveTypesWithTypeof.ts, 44, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 43, 10)) - -var hy2: { x: Array }; ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) ->Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11)) ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) - -var hy2 = hy2.x[0]; ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->hy2.x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) ->hy2 : Symbol(hy2, Decl(recursiveTypesWithTypeof.ts, 45, 3), Decl(recursiveTypesWithTypeof.ts, 46, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 45, 10)) - -interface Foo2 { } ->Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19)) ->T : Symbol(T, Decl(recursiveTypesWithTypeof.ts, 48, 15)) ->U : Symbol(U, Decl(recursiveTypesWithTypeof.ts, 48, 17)) - -// This one should be any because the first type argument is not contained inside a type literal -var hy3: Foo2; ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) ->Foo2 : Symbol(Foo2, Decl(recursiveTypesWithTypeof.ts, 46, 19)) ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) ->x : Symbol(x, Decl(recursiveTypesWithTypeof.ts, 51, 27)) ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) - -var hy3: any; ->hy3 : Symbol(hy3, Decl(recursiveTypesWithTypeof.ts, 51, 3), Decl(recursiveTypesWithTypeof.ts, 52, 3)) - diff --git a/tests/baselines/reference/recursiveTypesWithTypeof.types b/tests/baselines/reference/recursiveTypesWithTypeof.types deleted file mode 100644 index 864c136743d..00000000000 --- a/tests/baselines/reference/recursiveTypesWithTypeof.types +++ /dev/null @@ -1,201 +0,0 @@ -=== tests/cases/conformance/types/specifyingTypes/typeQueries/recursiveTypesWithTypeof.ts === -// None of these declarations should have any errors! -// Using typeof directly, these should be any -var c: typeof c; ->c : any ->c : any - -var c: any; ->c : any - -var d: typeof e; ->d : any ->e : any - -var d: any; ->d : any - -var e: typeof d; ->e : any ->d : any - -var e: any; ->e : any - -// In type arguments, these should be any -interface Foo { } ->Foo : Foo ->T : T - -var f: Array; ->f : any ->Array : T[] ->f : any - -var f: any; ->f : any - -var f2: Foo; ->f2 : any ->Foo : Foo ->f2 : any - -var f2: any; ->f2 : any - -var f3: Foo[]; ->f3 : any ->Foo : Foo ->f3 : any - -var f3: any; ->f3 : any - -// Truly recursive types -var g: { x: typeof g; }; ->g : { x: any; } ->x : { x: any; } ->g : { x: any; } - -var g: typeof g.x; ->g : { x: any; } ->g.x : { x: any; } ->g : { x: any; } ->x : { x: any; } - -var h: () => typeof h; ->h : () => any ->h : () => any - -var h = h(); ->h : () => any ->h() : () => any ->h : () => any - -var i: (x: typeof i) => typeof x; ->i : (x: any) => any ->x : (x: any) => any ->i : (x: any) => any ->x : (x: any) => any - -var i = i(i); ->i : (x: any) => any ->i(i) : (x: any) => any ->i : (x: any) => any ->i : (x: any) => any - -var j: (x: T) => T; ->j : (x: T) => T ->T : T ->j : (x: T) => T ->x : T ->T : T ->T : T - -var j = j(j); ->j : (x: T) => T ->j(j) : (x: T) => T ->j : (x: T) => T ->j : (x: T) => T - -// Same as h, i, j with construct signatures -var h2: new () => typeof h2; ->h2 : new () => any ->h2 : new () => any - -var h2 = new h2(); ->h2 : new () => any ->new h2() : new () => any ->h2 : new () => any - -var i2: new (x: typeof i2) => typeof x; ->i2 : new (x: any) => any ->x : new (x: any) => any ->i2 : new (x: any) => any ->x : new (x: any) => any - -var i2 = new i2(i2); ->i2 : new (x: any) => any ->new i2(i2) : new (x: any) => any ->i2 : new (x: any) => any ->i2 : new (x: any) => any - -var j2: new (x: T) => T; ->j2 : new (x: T) => T ->T : T ->j2 : new (x: T) => T ->x : T ->T : T ->T : T - -var j2 = new j2(j2); ->j2 : new (x: T) => T ->new j2(j2) : new (x: T) => T ->j2 : new (x: T) => T ->j2 : new (x: T) => T - -// Indexers -var k: { [n: number]: typeof k;[s: string]: typeof k }; ->k : { [s: string]: any; [n: number]: any; } ->n : number ->k : { [s: string]: any; [n: number]: any; } ->s : string ->k : { [s: string]: any; [n: number]: any; } - -var k = k[0]; ->k : { [s: string]: any; [n: number]: any; } ->k[0] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } ->0 : number - -var k = k['']; ->k : { [s: string]: any; [n: number]: any; } ->k[''] : { [s: string]: any; [n: number]: any; } ->k : { [s: string]: any; [n: number]: any; } ->'' : string - -// Hybrid - contains type literals as well as type arguments -// These two are recursive -var hy1: { x: typeof hy1 }[]; ->hy1 : { x: any[]; }[] ->x : { x: any[]; }[] ->hy1 : { x: any[]; }[] - -var hy1 = hy1[0].x; ->hy1 : { x: any[]; }[] ->hy1[0].x : { x: any[]; }[] ->hy1[0] : { x: any[]; } ->hy1 : { x: any[]; }[] ->0 : number ->x : { x: any[]; }[] - -var hy2: { x: Array }; ->hy2 : { x: any[]; } ->x : { x: any[]; }[] ->Array : T[] ->hy2 : { x: any[]; } - -var hy2 = hy2.x[0]; ->hy2 : { x: any[]; } ->hy2.x[0] : { x: any[]; } ->hy2.x : { x: any[]; }[] ->hy2 : { x: any[]; } ->x : { x: any[]; }[] ->0 : number - -interface Foo2 { } ->Foo2 : Foo2 ->T : T ->U : U - -// This one should be any because the first type argument is not contained inside a type literal -var hy3: Foo2; ->hy3 : any ->Foo2 : Foo2 ->hy3 : any ->x : any ->hy3 : any - -var hy3: any; ->hy3 : any - diff --git a/tests/baselines/reference/typeofANonExportedType.errors.txt b/tests/baselines/reference/typeofANonExportedType.errors.txt index b6b165cdd4f..d07468f62e1 100644 --- a/tests/baselines/reference/typeofANonExportedType.errors.txt +++ b/tests/baselines/reference/typeofANonExportedType.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(2,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (1 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType.ts (2 errors) ==== var x = 1; export var r1: typeof x; ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofANonExportedType export var r11: typeof E.A; export var r12: typeof r12; + ~~~ +!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. function foo() { } module foo { diff --git a/tests/baselines/reference/typeofAnExportedType.errors.txt b/tests/baselines/reference/typeofAnExportedType.errors.txt index 9f64f697c08..cb6d8c68887 100644 --- a/tests/baselines/reference/typeofAnExportedType.errors.txt +++ b/tests/baselines/reference/typeofAnExportedType.errors.txt @@ -1,7 +1,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts(42,12): error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. -==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (1 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.ts (2 errors) ==== export var x = 1; ~~~~~~~~~~~~~~~~~ !!! error TS1148: Cannot compile modules unless the '--module' flag is provided. @@ -46,6 +47,8 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofAnExportedType.t export var r11: typeof E.A; export var r12: typeof r12; + ~~~ +!!! error TS2502: 'r12' is referenced directly or indirectly in its own type annotation. export function foo() { } export module foo {