Skip to content

Commit 855488f

Browse files
committed
Add additional regression test
1 parent f1da780 commit 855488f

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

tests/baselines/reference/circularIndexedAccessErrors.errors.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(3,5): error T
22
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(7,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
33
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(19,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
44
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error TS2502: 'x' is referenced directly or indirectly in its own type annotation.
5+
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,24): error TS2313: Type parameter 'T' has a circular constraint.
6+
tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(38,30): error TS2536: Type '"hello"' cannot be used to index type 'T'.
57

68

7-
==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (4 errors) ====
9+
==== tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts (6 errors) ====
810

911
type T1 = {
1012
x: T1["x"]; // Error
@@ -42,4 +44,18 @@ tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts(23,5): error
4244
x: this["y"];
4345
y: this["z"];
4446
z: this["x"];
45-
}
47+
}
48+
49+
// Repro from #12627
50+
51+
interface Foo {
52+
hello: boolean;
53+
}
54+
55+
function foo<T extends Foo | T["hello"]>() {
56+
~~~~~~~~~~~~~~~~
57+
!!! error TS2313: Type parameter 'T' has a circular constraint.
58+
~~~~~~~~~~
59+
!!! error TS2536: Type '"hello"' cannot be used to index type 'T'.
60+
}
61+

tests/baselines/reference/circularIndexedAccessErrors.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,17 @@ class C2 {
2828
x: this["y"];
2929
y: this["z"];
3030
z: this["x"];
31-
}
31+
}
32+
33+
// Repro from #12627
34+
35+
interface Foo {
36+
hello: boolean;
37+
}
38+
39+
function foo<T extends Foo | T["hello"]>() {
40+
}
41+
3242

3343
//// [circularIndexedAccessErrors.js]
3444
var x2x = x2.x;
@@ -42,6 +52,8 @@ var C2 = (function () {
4252
}
4353
return C2;
4454
}());
55+
function foo() {
56+
}
4557

4658

4759
//// [circularIndexedAccessErrors.d.ts]
@@ -68,3 +80,7 @@ declare class C2 {
6880
y: this["z"];
6981
z: this["x"];
7082
}
83+
interface Foo {
84+
hello: boolean;
85+
}
86+
declare function foo<T extends Foo | T["hello"]>(): void;

tests/cases/conformance/types/keyof/circularIndexedAccessErrors.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,13 @@ class C2 {
2828
x: this["y"];
2929
y: this["z"];
3030
z: this["x"];
31-
}
31+
}
32+
33+
// Repro from #12627
34+
35+
interface Foo {
36+
hello: boolean;
37+
}
38+
39+
function foo<T extends Foo | T["hello"]>() {
40+
}

0 commit comments

Comments
 (0)