You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 941e494
Browse filesBrowse the repository at this point in the historyBrowse files
Decide whether a type reference can recurse from its type arguments
Comparing types assumes a comparison holds once it is nested in three
others of types with the same recursion identity. A type reference
created while resolving a type node was tracked by itself rather than
by its symbol, as it cannot be the source of generative recursion
without being instantiated. Type references are interned, so this
depended on how a reference was first created. In
interface A<T> {
slice(): B<T>;
every<S extends T>(predicate: (value: T) => value is S): this is A<S>;
flatMap<U>(callback: (value: T) => U | readonly U[] | A<U>): U[];
}
interface B<T> extends A<T> {}
const a: A<0> = [];
const b: B<0> = [];
B<0> was tracked by itself when the annotation of b was resolved before
checking a instantiated slice, and by its symbol otherwise, so the
comparison for b was cut short at different depths, changing the error
it reported. Cutting a comparison short can also change whether the
types are related. A type reference whose type arguments were not
themselves instantiated is now tracked by itself however it was
created.
For 54921
Copy file name to clipboardExpand all lines: tsc/testdata/baselines/reference/compiler/typeReferenceRecursionIdentityCheckOrder(checkorder=default).errors.txt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ typeReferenceRecursionIdentityCheckOrder.ts(12,7): error TS2322: Type 'never[]'
12
12
Type '{ <S extends never>(predicate: (value: never, index: number, array: never[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: never, index: number, array: never[]) => unknown, thisArg?: any): boolean; }' is not assignable to type '<S extends 0>(predicate: (value: 0) => value is S) => this is A<S>'.
13
13
Type predicate 'this is any[]' is not assignable to 'this is A<any>'.
14
14
Type 'any[]' is not assignable to type 'A<any>'.
15
-
The types returned by 'flatMap(...)' are incompatible between these types.
15
+
The types returned by 'slice(...).flatMap(...)' are incompatible between these types.
16
16
Type '(U | A<U>)[]' is not assignable to type 'U[]'.
17
17
Type 'U | A<U>' is not assignable to type 'U'.
18
18
'U' could be instantiated with an arbitrary type which could be unrelated to 'U | A<U>'.
@@ -47,7 +47,7 @@ typeReferenceRecursionIdentityCheckOrder.ts(12,7): error TS2322: Type 'never[]'
47
47
!!! error TS2322: Type '{ <S extends never>(predicate: (value: never, index: number, array: never[]) => value is S, thisArg?: any): this is S[]; (predicate: (value: never, index: number, array: never[]) => unknown, thisArg?: any): boolean; }' is not assignable to type '<S extends 0>(predicate: (value: 0) => value is S) => this is A<S>'.
48
48
!!! error TS2322: Type predicate 'this is any[]' is not assignable to 'this is A<any>'.
49
49
!!! error TS2322: Type 'any[]' is not assignable to type 'A<any>'.
50
-
!!! error TS2322: The types returned by 'flatMap(...)' are incompatible between these types.
50
+
!!! error TS2322: The types returned by 'slice(...).flatMap(...)' are incompatible between these types.
51
51
!!! error TS2322: Type '(U | A<U>)[]' is not assignable to type 'U[]'.
52
52
!!! error TS2322: Type 'U | A<U>' is not assignable to type 'U'.
53
53
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'U | A<U>'.
0 commit comments