From 855488fc6d5b9311b463da64f1d32d00ea58cce2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 6 Jan 2017 17:35:09 -0800 Subject: [PATCH] Add additional regression test --- .../circularIndexedAccessErrors.errors.txt | 20 +++++++++++++++++-- .../reference/circularIndexedAccessErrors.js | 18 ++++++++++++++++- .../keyof/circularIndexedAccessErrors.ts | 11 +++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt index e5eaa08d05..f76cfca073 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/circularIndexedAccessErrors.errors.txt @@ -2,9 +2,11 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error T tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint. +tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'. -==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (4 errors) ==== +==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ==== type T1 = { x: T1["x"]; // Error @@ -42,4 +44,18 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error x: this["y"]; y: this["z"]; z: this["x"]; - } \ No newline at end of file + } + + // Repro from #12627 + + interface Foo { + hello: boolean; + } + + function foo() { + ~~~~~~~~~~~~~~~~ +!!! error TS2313: Type parameter 'T' has a circular constraint. + ~~~~~~~~~~ +!!! error TS2536: Type '"hello"' cannot be used to index type 'T'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/circularIndexedAccessErrors.js b/tests/baselines/reference/circularIndexedAccessErrors.js index 2e4ae3bd84..97d059bce1 100644 --- a/tests/baselines/reference/circularIndexedAccessErrors.js +++ b/tests/baselines/reference/circularIndexedAccessErrors.js @@ -28,7 +28,17 @@ class C2 { x: this["y"]; y: this["z"]; z: this["x"]; -} +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +} + //// [circularIndexedAccessErrors.js] var x2x = x2.x; @@ -42,6 +52,8 @@ var C2 = (function () { } return C2; }()); +function foo() { +} //// [circularIndexedAccessErrors.d.ts] @@ -68,3 +80,7 @@ declare class C2 { y: this["z"]; z: this["x"]; } +interface Foo { + hello: boolean; +} +declare function foo(): void; diff --git a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts index 2243ee8aaa..a53fc6fbf7 100644 --- a/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts +++ b/tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts @@ -28,4 +28,13 @@ class C2 { x: this["y"]; y: this["z"]; z: this["x"]; -} \ No newline at end of file +} + +// Repro from #12627 + +interface Foo { + hello: boolean; +} + +function foo() { +}