Skip to content

Commit 47c61fd

Browse files
Fix lint warning in array recursion identity change
Agent-Logs-Url: https://github.com/RyanCavanaugh/TypeScript/sessions/dee5edef-e472-4317-8876-e1ca781fb3bf Co-authored-by: RyanCavanaugh <[email protected]>
1 parent aa2f1b8 commit 47c61fd

5 files changed

Lines changed: 280 additions & 1 deletion

File tree

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25303,7 +25303,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2530325303
if (isArrayType(type)) {
2530425304
// Array wrappers are common and finite in non-recursive object graphs; track recursion identity through
2530525305
// the element type instead of the shared global Array symbol to avoid false positives in deep nesting.
25306-
return getRecursionIdentity(getTypeArguments(type as TypeReference)[0]);
25306+
return getRecursionIdentity(getTypeArguments(type)[0]);
2530725307
}
2530825308
if (getObjectFlags(type) & ObjectFlags.Reference && (type as TypeReference).node) {
2530925309
// Deferred type references are tracked through their associated AST node. This gives us finer
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
issue52912.ts(18,7): error TS2322: Type 'Source1' is not assignable to type 'Target1'.
2+
Types of property 'array' are incompatible.
3+
Type 'Source2[]' is not assignable to type 'Target2[]'.
4+
Type 'Source2' is not assignable to type 'Target2'.
5+
Types of property 'array' are incompatible.
6+
Type 'Source3[]' is not assignable to type 'Target3[]'.
7+
Type 'Source3' is not assignable to type 'Target3'.
8+
Types of property 'array' are incompatible.
9+
Type 'Source4[]' is not assignable to type 'Target4[]'.
10+
Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
11+
issue52912.ts(19,7): error TS2322: Type 'Source2' is not assignable to type 'Target2'.
12+
Types of property 'array' are incompatible.
13+
Type 'Source3[]' is not assignable to type 'Target3[]'.
14+
Type 'Source3' is not assignable to type 'Target3'.
15+
Types of property 'array' are incompatible.
16+
Type 'Source4[]' is not assignable to type 'Target4[]'.
17+
Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
18+
issue52912.ts(20,7): error TS2322: Type 'Source3' is not assignable to type 'Target3'.
19+
Types of property 'array' are incompatible.
20+
Type 'Source4[]' is not assignable to type 'Target4[]'.
21+
Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
22+
issue52912.ts(21,7): error TS2741: Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
23+
24+
25+
==== issue52912.ts (4 errors) ====
26+
// Repro from #52912
27+
28+
type Source1 = { array: Source2[] };
29+
type Source2 = { array: Source3[] };
30+
type Source3 = { array: Source4[] };
31+
type Source4 = {};
32+
33+
type Target1 = { array: Target2[] };
34+
type Target2 = { array: Target3[] };
35+
type Target3 = { array: Target4[] };
36+
type Target4 = { someNewProperty: string };
37+
38+
declare const source1: Source1;
39+
declare const source2: Source2;
40+
declare const source3: Source3;
41+
declare const source4: Source4;
42+
43+
const target1: Target1 = source1; // Error
44+
~~~~~~~
45+
!!! error TS2322: Type 'Source1' is not assignable to type 'Target1'.
46+
!!! error TS2322: Types of property 'array' are incompatible.
47+
!!! error TS2322: Type 'Source2[]' is not assignable to type 'Target2[]'.
48+
!!! error TS2322: Type 'Source2' is not assignable to type 'Target2'.
49+
!!! error TS2322: Types of property 'array' are incompatible.
50+
!!! error TS2322: Type 'Source3[]' is not assignable to type 'Target3[]'.
51+
!!! error TS2322: Type 'Source3' is not assignable to type 'Target3'.
52+
!!! error TS2322: Types of property 'array' are incompatible.
53+
!!! error TS2322: Type 'Source4[]' is not assignable to type 'Target4[]'.
54+
!!! error TS2322: Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
55+
!!! related TS2728 issue52912.ts:11:18: 'someNewProperty' is declared here.
56+
const target2: Target2 = source2; // Error
57+
~~~~~~~
58+
!!! error TS2322: Type 'Source2' is not assignable to type 'Target2'.
59+
!!! error TS2322: Types of property 'array' are incompatible.
60+
!!! error TS2322: Type 'Source3[]' is not assignable to type 'Target3[]'.
61+
!!! error TS2322: Type 'Source3' is not assignable to type 'Target3'.
62+
!!! error TS2322: Types of property 'array' are incompatible.
63+
!!! error TS2322: Type 'Source4[]' is not assignable to type 'Target4[]'.
64+
!!! error TS2322: Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
65+
!!! related TS2728 issue52912.ts:11:18: 'someNewProperty' is declared here.
66+
const target3: Target3 = source3; // Error
67+
~~~~~~~
68+
!!! error TS2322: Type 'Source3' is not assignable to type 'Target3'.
69+
!!! error TS2322: Types of property 'array' are incompatible.
70+
!!! error TS2322: Type 'Source4[]' is not assignable to type 'Target4[]'.
71+
!!! error TS2322: Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
72+
!!! related TS2728 issue52912.ts:11:18: 'someNewProperty' is declared here.
73+
const target4: Target4 = source4; // Error
74+
~~~~~~~
75+
!!! error TS2741: Property 'someNewProperty' is missing in type 'Source4' but required in type 'Target4'.
76+
!!! related TS2728 issue52912.ts:11:18: 'someNewProperty' is declared here.
77+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//// [tests/cases/compiler/issue52912.ts] ////
2+
3+
//// [issue52912.ts]
4+
// Repro from #52912
5+
6+
type Source1 = { array: Source2[] };
7+
type Source2 = { array: Source3[] };
8+
type Source3 = { array: Source4[] };
9+
type Source4 = {};
10+
11+
type Target1 = { array: Target2[] };
12+
type Target2 = { array: Target3[] };
13+
type Target3 = { array: Target4[] };
14+
type Target4 = { someNewProperty: string };
15+
16+
declare const source1: Source1;
17+
declare const source2: Source2;
18+
declare const source3: Source3;
19+
declare const source4: Source4;
20+
21+
const target1: Target1 = source1; // Error
22+
const target2: Target2 = source2; // Error
23+
const target3: Target3 = source3; // Error
24+
const target4: Target4 = source4; // Error
25+
26+
27+
//// [issue52912.js]
28+
"use strict";
29+
// Repro from #52912
30+
const target1 = source1; // Error
31+
const target2 = source2; // Error
32+
const target3 = source3; // Error
33+
const target4 = source4; // Error
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//// [tests/cases/compiler/issue52912.ts] ////
2+
3+
=== issue52912.ts ===
4+
// Repro from #52912
5+
6+
type Source1 = { array: Source2[] };
7+
>Source1 : Symbol(Source1, Decl(issue52912.ts, 0, 0))
8+
>array : Symbol(array, Decl(issue52912.ts, 2, 16))
9+
>Source2 : Symbol(Source2, Decl(issue52912.ts, 2, 36))
10+
11+
type Source2 = { array: Source3[] };
12+
>Source2 : Symbol(Source2, Decl(issue52912.ts, 2, 36))
13+
>array : Symbol(array, Decl(issue52912.ts, 3, 16))
14+
>Source3 : Symbol(Source3, Decl(issue52912.ts, 3, 36))
15+
16+
type Source3 = { array: Source4[] };
17+
>Source3 : Symbol(Source3, Decl(issue52912.ts, 3, 36))
18+
>array : Symbol(array, Decl(issue52912.ts, 4, 16))
19+
>Source4 : Symbol(Source4, Decl(issue52912.ts, 4, 36))
20+
21+
type Source4 = {};
22+
>Source4 : Symbol(Source4, Decl(issue52912.ts, 4, 36))
23+
24+
type Target1 = { array: Target2[] };
25+
>Target1 : Symbol(Target1, Decl(issue52912.ts, 5, 18))
26+
>array : Symbol(array, Decl(issue52912.ts, 7, 16))
27+
>Target2 : Symbol(Target2, Decl(issue52912.ts, 7, 36))
28+
29+
type Target2 = { array: Target3[] };
30+
>Target2 : Symbol(Target2, Decl(issue52912.ts, 7, 36))
31+
>array : Symbol(array, Decl(issue52912.ts, 8, 16))
32+
>Target3 : Symbol(Target3, Decl(issue52912.ts, 8, 36))
33+
34+
type Target3 = { array: Target4[] };
35+
>Target3 : Symbol(Target3, Decl(issue52912.ts, 8, 36))
36+
>array : Symbol(array, Decl(issue52912.ts, 9, 16))
37+
>Target4 : Symbol(Target4, Decl(issue52912.ts, 9, 36))
38+
39+
type Target4 = { someNewProperty: string };
40+
>Target4 : Symbol(Target4, Decl(issue52912.ts, 9, 36))
41+
>someNewProperty : Symbol(someNewProperty, Decl(issue52912.ts, 10, 16))
42+
43+
declare const source1: Source1;
44+
>source1 : Symbol(source1, Decl(issue52912.ts, 12, 13))
45+
>Source1 : Symbol(Source1, Decl(issue52912.ts, 0, 0))
46+
47+
declare const source2: Source2;
48+
>source2 : Symbol(source2, Decl(issue52912.ts, 13, 13))
49+
>Source2 : Symbol(Source2, Decl(issue52912.ts, 2, 36))
50+
51+
declare const source3: Source3;
52+
>source3 : Symbol(source3, Decl(issue52912.ts, 14, 13))
53+
>Source3 : Symbol(Source3, Decl(issue52912.ts, 3, 36))
54+
55+
declare const source4: Source4;
56+
>source4 : Symbol(source4, Decl(issue52912.ts, 15, 13))
57+
>Source4 : Symbol(Source4, Decl(issue52912.ts, 4, 36))
58+
59+
const target1: Target1 = source1; // Error
60+
>target1 : Symbol(target1, Decl(issue52912.ts, 17, 5))
61+
>Target1 : Symbol(Target1, Decl(issue52912.ts, 5, 18))
62+
>source1 : Symbol(source1, Decl(issue52912.ts, 12, 13))
63+
64+
const target2: Target2 = source2; // Error
65+
>target2 : Symbol(target2, Decl(issue52912.ts, 18, 5))
66+
>Target2 : Symbol(Target2, Decl(issue52912.ts, 7, 36))
67+
>source2 : Symbol(source2, Decl(issue52912.ts, 13, 13))
68+
69+
const target3: Target3 = source3; // Error
70+
>target3 : Symbol(target3, Decl(issue52912.ts, 19, 5))
71+
>Target3 : Symbol(Target3, Decl(issue52912.ts, 8, 36))
72+
>source3 : Symbol(source3, Decl(issue52912.ts, 14, 13))
73+
74+
const target4: Target4 = source4; // Error
75+
>target4 : Symbol(target4, Decl(issue52912.ts, 20, 5))
76+
>Target4 : Symbol(Target4, Decl(issue52912.ts, 9, 36))
77+
>source4 : Symbol(source4, Decl(issue52912.ts, 15, 13))
78+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//// [tests/cases/compiler/issue52912.ts] ////
2+
3+
=== issue52912.ts ===
4+
// Repro from #52912
5+
6+
type Source1 = { array: Source2[] };
7+
>Source1 : Source1
8+
> : ^^^^^^^
9+
>array : Source2[]
10+
> : ^^^^^^^^^
11+
12+
type Source2 = { array: Source3[] };
13+
>Source2 : Source2
14+
> : ^^^^^^^
15+
>array : Source3[]
16+
> : ^^^^^^^^^
17+
18+
type Source3 = { array: Source4[] };
19+
>Source3 : Source3
20+
> : ^^^^^^^
21+
>array : Source4[]
22+
> : ^^^^^^^^^
23+
24+
type Source4 = {};
25+
>Source4 : Source4
26+
> : ^^^^^^^
27+
28+
type Target1 = { array: Target2[] };
29+
>Target1 : Target1
30+
> : ^^^^^^^
31+
>array : Target2[]
32+
> : ^^^^^^^^^
33+
34+
type Target2 = { array: Target3[] };
35+
>Target2 : Target2
36+
> : ^^^^^^^
37+
>array : Target3[]
38+
> : ^^^^^^^^^
39+
40+
type Target3 = { array: Target4[] };
41+
>Target3 : Target3
42+
> : ^^^^^^^
43+
>array : Target4[]
44+
> : ^^^^^^^^^
45+
46+
type Target4 = { someNewProperty: string };
47+
>Target4 : Target4
48+
> : ^^^^^^^
49+
>someNewProperty : string
50+
> : ^^^^^^
51+
52+
declare const source1: Source1;
53+
>source1 : Source1
54+
> : ^^^^^^^
55+
56+
declare const source2: Source2;
57+
>source2 : Source2
58+
> : ^^^^^^^
59+
60+
declare const source3: Source3;
61+
>source3 : Source3
62+
> : ^^^^^^^
63+
64+
declare const source4: Source4;
65+
>source4 : Source4
66+
> : ^^^^^^^
67+
68+
const target1: Target1 = source1; // Error
69+
>target1 : Target1
70+
> : ^^^^^^^
71+
>source1 : Source1
72+
> : ^^^^^^^
73+
74+
const target2: Target2 = source2; // Error
75+
>target2 : Target2
76+
> : ^^^^^^^
77+
>source2 : Source2
78+
> : ^^^^^^^
79+
80+
const target3: Target3 = source3; // Error
81+
>target3 : Target3
82+
> : ^^^^^^^
83+
>source3 : Source3
84+
> : ^^^^^^^
85+
86+
const target4: Target4 = source4; // Error
87+
>target4 : Target4
88+
> : ^^^^^^^
89+
>source4 : Source4
90+
> : ^^^^^^^
91+

0 commit comments

Comments
 (0)