Skip to content

Commit ac5884a

Browse files
cherry pick "No this type arguments in base constraints (#54536)" to release-5.1 (#54814)
Co-authored-by: Anders Hejlsberg <[email protected]>
1 parent e7f1caf commit ac5884a

File tree

6 files changed

+188
-27
lines changed

6 files changed

+188
-27
lines changed

src/compiler/checker.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12499,10 +12499,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1249912499
if (getObjectFlags(type) & ObjectFlags.Reference) {
1250012500
const target = (type as TypeReference).target;
1250112501
const typeArguments = getTypeArguments(type as TypeReference);
12502-
if (length(target.typeParameters) === length(typeArguments)) {
12503-
const ref = createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType!]));
12504-
return needApparentType ? getApparentType(ref) : ref;
12505-
}
12502+
return length(target.typeParameters) === length(typeArguments) ? createTypeReference(target, concatenate(typeArguments, [thisArgument || target.thisType!])) : type;
1250612503
}
1250712504
else if (type.flags & TypeFlags.Intersection) {
1250812505
const types = sameMap((type as IntersectionType).types, t => getTypeWithThisArgument(t, thisArgument, needApparentType));
@@ -12511,10 +12508,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1251112508
return needApparentType ? getApparentType(type) : type;
1251212509
}
1251312510

12514-
function getThisArgument(type: Type) {
12515-
return getObjectFlags(type) & ObjectFlags.Reference && length(getTypeArguments(type as TypeReference)) > getTypeReferenceArity(type as TypeReference) ? last(getTypeArguments(type as TypeReference)) : type;
12516-
}
12517-
1251812511
function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: readonly TypeParameter[], typeArguments: readonly Type[]) {
1251912512
let mapper: TypeMapper | undefined;
1252012513
let members: SymbolTable;
@@ -13696,7 +13689,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1369613689
return type.resolvedBaseConstraint;
1369713690
}
1369813691
const stack: object[] = [];
13699-
return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), getThisArgument(type));
13692+
return type.resolvedBaseConstraint = getImmediateBaseConstraint(type);
1370013693

1370113694
function getImmediateBaseConstraint(t: Type): Type {
1370213695
if (!t.immediateBaseConstraint) {
@@ -13802,17 +13795,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1380213795
// We substitute constraints for variadic elements only when the constraints are array types or
1380313796
// non-variadic tuple types as we want to avoid further (possibly unbounded) recursion.
1380413797
const newElements = map(getElementTypes(t), (v, i) => {
13805-
const constraint = t.target.elementFlags[i] & ElementFlags.Variadic && getBaseConstraint(v) || v;
13806-
return constraint && everyType(constraint, c => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
13798+
const constraint = v.flags & TypeFlags.TypeParameter && t.target.elementFlags[i] & ElementFlags.Variadic && getBaseConstraint(v) || v;
13799+
return constraint !== v && everyType(constraint, c => isArrayOrTupleType(c) && !isGenericTupleType(c)) ? constraint : v;
1380713800
});
1380813801
return createTupleType(newElements, t.target.elementFlags, t.target.readonly, t.target.labeledElementDeclarations);
1380913802
}
1381013803
return t;
1381113804
}
1381213805
}
1381313806

13814-
function getApparentTypeOfIntersectionType(type: IntersectionType) {
13815-
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, /*needApparentType*/ true));
13807+
function getApparentTypeOfIntersectionType(type: IntersectionType, thisArgument: Type) {
13808+
return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, thisArgument, /*needApparentType*/ true));
1381613809
}
1381713810

1381813811
function getResolvedTypeParameterDefault(typeParameter: TypeParameter): Type | undefined {
@@ -13890,9 +13883,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1389013883
* type itself.
1389113884
*/
1389213885
function getApparentType(type: Type): Type {
13893-
const t = !(type.flags & TypeFlags.Instantiable) ? type : getBaseConstraintOfType(type) || unknownType;
13894-
return getObjectFlags(t) & ObjectFlags.Mapped ? getApparentTypeOfMappedType(t as MappedType) :
13895-
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType) :
13886+
const t = type.flags & TypeFlags.Instantiable ? getBaseConstraintOfType(type) || unknownType : type;
13887+
const objectFlags = getObjectFlags(t);
13888+
return objectFlags & ObjectFlags.Mapped ? getApparentTypeOfMappedType(t as MappedType) :
13889+
objectFlags & ObjectFlags.Reference && t !== type ? getTypeWithThisArgument(t, type) :
13890+
t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t as IntersectionType, type) :
1389613891
t.flags & TypeFlags.StringLike ? globalStringType :
1389713892
t.flags & TypeFlags.NumberLike ? globalNumberType :
1389813893
t.flags & TypeFlags.BigIntLike ? getGlobalBigIntType() :
@@ -21570,9 +21565,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2157021565
}
2157121566
const c = target as ConditionalType;
2157221567
// We check for a relationship to a conditional type target only when the conditional type has no
21573-
// 'infer' positions and is not distributive or is distributive but doesn't reference the check type
21574-
// parameter in either of the result types.
21575-
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) {
21568+
// 'infer' positions, is not distributive or is distributive but doesn't reference the check type
21569+
// parameter in either of the result types, and the source isn't an instantiation of the same
21570+
// conditional type (as happens when computing variance).
21571+
if (!c.root.inferTypeParameters && !isDistributionDependent(c.root) && !(source.flags & TypeFlags.Conditional && (source as ConditionalType).root === c.root)) {
2157621572
// Check if the conditional is always true or always false but still deferred for distribution purposes.
2157721573
const skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType));
2157821574
const skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType));

tests/baselines/reference/complexRecursiveCollections.errors.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
tests/cases/compiler/immutable.ts(341,22): error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
22
The types returned by 'toSeq()' are incompatible between these types.
33
Type 'Keyed<K, V>' is not assignable to type 'this'.
4-
'this' could be instantiated with an arbitrary type which could be unrelated to 'Keyed<K, V>'.
4+
'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
55
tests/cases/compiler/immutable.ts(359,22): error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
66
The types returned by 'toSeq()' are incompatible between these types.
77
Type 'Indexed<T>' is not assignable to type 'this'.
8-
'this' could be instantiated with an arbitrary type which could be unrelated to 'Indexed<T>'.
8+
'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
99
tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
1010
The types returned by 'toSeq()' are incompatible between these types.
1111
Type 'Set<T>' is not assignable to type 'this'.
12-
'this' could be instantiated with an arbitrary type which could be unrelated to 'Set<T>'.
12+
'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
1313

1414

1515
==== tests/cases/compiler/complex.ts (0 errors) ====
@@ -379,7 +379,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
379379
!!! error TS2430: Interface 'Keyed<K, V>' incorrectly extends interface 'Collection<K, V>'.
380380
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
381381
!!! error TS2430: Type 'Keyed<K, V>' is not assignable to type 'this'.
382-
!!! error TS2430: 'this' could be instantiated with an arbitrary type which could be unrelated to 'Keyed<K, V>'.
382+
!!! error TS2430: 'Keyed<K, V>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Keyed<K, V>'.
383383
toJS(): Object;
384384
toJSON(): { [key: string]: V };
385385
toSeq(): Seq.Keyed<K, V>;
@@ -402,7 +402,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
402402
!!! error TS2430: Interface 'Indexed<T>' incorrectly extends interface 'Collection<number, T>'.
403403
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
404404
!!! error TS2430: Type 'Indexed<T>' is not assignable to type 'this'.
405-
!!! error TS2430: 'this' could be instantiated with an arbitrary type which could be unrelated to 'Indexed<T>'.
405+
!!! error TS2430: 'Indexed<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Indexed<T>'.
406406
toJS(): Array<any>;
407407
toJSON(): Array<T>;
408408
// Reading values
@@ -439,7 +439,7 @@ tests/cases/compiler/immutable.ts(391,22): error TS2430: Interface 'Set<T>' inco
439439
!!! error TS2430: Interface 'Set<T>' incorrectly extends interface 'Collection<never, T>'.
440440
!!! error TS2430: The types returned by 'toSeq()' are incompatible between these types.
441441
!!! error TS2430: Type 'Set<T>' is not assignable to type 'this'.
442-
!!! error TS2430: 'this' could be instantiated with an arbitrary type which could be unrelated to 'Set<T>'.
442+
!!! error TS2430: 'Set<T>' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Set<T>'.
443443
toJS(): Array<any>;
444444
toJSON(): Array<T>;
445445
toSeq(): Seq.Set<T>;
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
=== tests/cases/compiler/largeTupleTypes.ts ===
2+
// Repro from #54491
3+
4+
type UnshiftTuple<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? Tail : never;
5+
>UnshiftTuple : Symbol(UnshiftTuple, Decl(largeTupleTypes.ts, 0, 0))
6+
>T : Symbol(T, Decl(largeTupleTypes.ts, 2, 18))
7+
>T : Symbol(T, Decl(largeTupleTypes.ts, 2, 18))
8+
>T : Symbol(T, Decl(largeTupleTypes.ts, 2, 18))
9+
>Tail : Symbol(Tail, Decl(largeTupleTypes.ts, 2, 67))
10+
>Tail : Symbol(Tail, Decl(largeTupleTypes.ts, 2, 67))
11+
12+
type ExpandSmallerTuples<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? T | ExpandSmallerTuples<Tail> : [];
13+
>ExpandSmallerTuples : Symbol(ExpandSmallerTuples, Decl(largeTupleTypes.ts, 2, 89))
14+
>T : Symbol(T, Decl(largeTupleTypes.ts, 3, 25))
15+
>T : Symbol(T, Decl(largeTupleTypes.ts, 3, 25))
16+
>T : Symbol(T, Decl(largeTupleTypes.ts, 3, 25))
17+
>Tail : Symbol(Tail, Decl(largeTupleTypes.ts, 3, 74))
18+
>T : Symbol(T, Decl(largeTupleTypes.ts, 3, 25))
19+
>ExpandSmallerTuples : Symbol(ExpandSmallerTuples, Decl(largeTupleTypes.ts, 2, 89))
20+
>Tail : Symbol(Tail, Decl(largeTupleTypes.ts, 3, 74))
21+
22+
type Shift<A extends Array<any>> = ((...args: A) => void) extends (...args: [A[0], ...infer R]) => void ? R : never;
23+
>Shift : Symbol(Shift, Decl(largeTupleTypes.ts, 3, 118))
24+
>A : Symbol(A, Decl(largeTupleTypes.ts, 4, 11))
25+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
26+
>args : Symbol(args, Decl(largeTupleTypes.ts, 4, 37))
27+
>A : Symbol(A, Decl(largeTupleTypes.ts, 4, 11))
28+
>args : Symbol(args, Decl(largeTupleTypes.ts, 4, 67))
29+
>A : Symbol(A, Decl(largeTupleTypes.ts, 4, 11))
30+
>R : Symbol(R, Decl(largeTupleTypes.ts, 4, 91))
31+
>R : Symbol(R, Decl(largeTupleTypes.ts, 4, 91))
32+
33+
type GrowExpRev<A extends Array<any>, N extends number, P extends Array<Array<any>>> = A['length'] extends N ? A : GrowExpRev<[...A, ...P[0]][N] extends undefined ? [...A, ...P[0]] : A, N, Shift<P>>;
34+
>GrowExpRev : Symbol(GrowExpRev, Decl(largeTupleTypes.ts, 4, 116))
35+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
36+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
37+
>N : Symbol(N, Decl(largeTupleTypes.ts, 5, 37))
38+
>P : Symbol(P, Decl(largeTupleTypes.ts, 5, 55))
39+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
40+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
41+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
42+
>N : Symbol(N, Decl(largeTupleTypes.ts, 5, 37))
43+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
44+
>GrowExpRev : Symbol(GrowExpRev, Decl(largeTupleTypes.ts, 4, 116))
45+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
46+
>P : Symbol(P, Decl(largeTupleTypes.ts, 5, 55))
47+
>N : Symbol(N, Decl(largeTupleTypes.ts, 5, 37))
48+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
49+
>P : Symbol(P, Decl(largeTupleTypes.ts, 5, 55))
50+
>A : Symbol(A, Decl(largeTupleTypes.ts, 5, 16))
51+
>N : Symbol(N, Decl(largeTupleTypes.ts, 5, 37))
52+
>Shift : Symbol(Shift, Decl(largeTupleTypes.ts, 3, 118))
53+
>P : Symbol(P, Decl(largeTupleTypes.ts, 5, 55))
54+
55+
type GrowExp<A extends Array<any>, N extends number, P extends Array<Array<any>>> = [...A, ...A][N] extends undefined ? GrowExp<[...A, ...A], N, [A, ...P]> : GrowExpRev<A, N, P>;
56+
>GrowExp : Symbol(GrowExp, Decl(largeTupleTypes.ts, 5, 199))
57+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
58+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
59+
>N : Symbol(N, Decl(largeTupleTypes.ts, 6, 34))
60+
>P : Symbol(P, Decl(largeTupleTypes.ts, 6, 52))
61+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
62+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
63+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
64+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
65+
>N : Symbol(N, Decl(largeTupleTypes.ts, 6, 34))
66+
>GrowExp : Symbol(GrowExp, Decl(largeTupleTypes.ts, 5, 199))
67+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
68+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
69+
>N : Symbol(N, Decl(largeTupleTypes.ts, 6, 34))
70+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
71+
>P : Symbol(P, Decl(largeTupleTypes.ts, 6, 52))
72+
>GrowExpRev : Symbol(GrowExpRev, Decl(largeTupleTypes.ts, 4, 116))
73+
>A : Symbol(A, Decl(largeTupleTypes.ts, 6, 13))
74+
>N : Symbol(N, Decl(largeTupleTypes.ts, 6, 34))
75+
>P : Symbol(P, Decl(largeTupleTypes.ts, 6, 52))
76+
77+
type Tuple<T, N extends number> = number extends N ? Array<T> : N extends 0 ? [] : N extends 1 ? [T] : GrowExp<[T], N, [[]]>;
78+
>Tuple : Symbol(Tuple, Decl(largeTupleTypes.ts, 6, 178))
79+
>T : Symbol(T, Decl(largeTupleTypes.ts, 7, 11))
80+
>N : Symbol(N, Decl(largeTupleTypes.ts, 7, 13))
81+
>N : Symbol(N, Decl(largeTupleTypes.ts, 7, 13))
82+
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
83+
>T : Symbol(T, Decl(largeTupleTypes.ts, 7, 11))
84+
>N : Symbol(N, Decl(largeTupleTypes.ts, 7, 13))
85+
>N : Symbol(N, Decl(largeTupleTypes.ts, 7, 13))
86+
>T : Symbol(T, Decl(largeTupleTypes.ts, 7, 11))
87+
>GrowExp : Symbol(GrowExp, Decl(largeTupleTypes.ts, 5, 199))
88+
>T : Symbol(T, Decl(largeTupleTypes.ts, 7, 11))
89+
>N : Symbol(N, Decl(largeTupleTypes.ts, 7, 13))
90+
91+
declare class ArrayValidator<T extends unknown[], I = T[number]> {
92+
>ArrayValidator : Symbol(ArrayValidator, Decl(largeTupleTypes.ts, 7, 125))
93+
>T : Symbol(T, Decl(largeTupleTypes.ts, 9, 29))
94+
>I : Symbol(I, Decl(largeTupleTypes.ts, 9, 49))
95+
>T : Symbol(T, Decl(largeTupleTypes.ts, 9, 29))
96+
97+
lengthRange<S extends number, E extends number>(start: S, endBefore: E): ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>]>>>>;
98+
>lengthRange : Symbol(ArrayValidator.lengthRange, Decl(largeTupleTypes.ts, 9, 66))
99+
>S : Symbol(S, Decl(largeTupleTypes.ts, 10, 16))
100+
>E : Symbol(E, Decl(largeTupleTypes.ts, 10, 33))
101+
>start : Symbol(start, Decl(largeTupleTypes.ts, 10, 52))
102+
>S : Symbol(S, Decl(largeTupleTypes.ts, 10, 16))
103+
>endBefore : Symbol(endBefore, Decl(largeTupleTypes.ts, 10, 61))
104+
>E : Symbol(E, Decl(largeTupleTypes.ts, 10, 33))
105+
>ArrayValidator : Symbol(ArrayValidator, Decl(largeTupleTypes.ts, 7, 125))
106+
>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --))
107+
>ExpandSmallerTuples : Symbol(ExpandSmallerTuples, Decl(largeTupleTypes.ts, 2, 89))
108+
>UnshiftTuple : Symbol(UnshiftTuple, Decl(largeTupleTypes.ts, 0, 0))
109+
>Tuple : Symbol(Tuple, Decl(largeTupleTypes.ts, 6, 178))
110+
>I : Symbol(I, Decl(largeTupleTypes.ts, 9, 49))
111+
>E : Symbol(E, Decl(largeTupleTypes.ts, 10, 33))
112+
>ExpandSmallerTuples : Symbol(ExpandSmallerTuples, Decl(largeTupleTypes.ts, 2, 89))
113+
>UnshiftTuple : Symbol(UnshiftTuple, Decl(largeTupleTypes.ts, 0, 0))
114+
>Tuple : Symbol(Tuple, Decl(largeTupleTypes.ts, 6, 178))
115+
>I : Symbol(I, Decl(largeTupleTypes.ts, 9, 49))
116+
>S : Symbol(S, Decl(largeTupleTypes.ts, 10, 16))
117+
}
118+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
=== tests/cases/compiler/largeTupleTypes.ts ===
2+
// Repro from #54491
3+
4+
type UnshiftTuple<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? Tail : never;
5+
>UnshiftTuple : UnshiftTuple<T>
6+
7+
type ExpandSmallerTuples<T extends [...any[]]> = T extends [T[0], ...infer Tail] ? T | ExpandSmallerTuples<Tail> : [];
8+
>ExpandSmallerTuples : ExpandSmallerTuples<T>
9+
10+
type Shift<A extends Array<any>> = ((...args: A) => void) extends (...args: [A[0], ...infer R]) => void ? R : never;
11+
>Shift : Shift<A>
12+
>args : A
13+
>args : [A[0], ...R]
14+
15+
type GrowExpRev<A extends Array<any>, N extends number, P extends Array<Array<any>>> = A['length'] extends N ? A : GrowExpRev<[...A, ...P[0]][N] extends undefined ? [...A, ...P[0]] : A, N, Shift<P>>;
16+
>GrowExpRev : GrowExpRev<A, N, P>
17+
18+
type GrowExp<A extends Array<any>, N extends number, P extends Array<Array<any>>> = [...A, ...A][N] extends undefined ? GrowExp<[...A, ...A], N, [A, ...P]> : GrowExpRev<A, N, P>;
19+
>GrowExp : GrowExp<A, N, P>
20+
21+
type Tuple<T, N extends number> = number extends N ? Array<T> : N extends 0 ? [] : N extends 1 ? [T] : GrowExp<[T], N, [[]]>;
22+
>Tuple : Tuple<T, N>
23+
24+
declare class ArrayValidator<T extends unknown[], I = T[number]> {
25+
>ArrayValidator : ArrayValidator<T, I>
26+
27+
lengthRange<S extends number, E extends number>(start: S, endBefore: E): ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>]>>>>;
28+
>lengthRange : <S extends number, E extends number>(start: S, endBefore: E) => ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>]>>>>
29+
>start : S
30+
>endBefore : E
31+
}
32+

tests/baselines/reference/mergedDeclarations7.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'.
22
The types returned by 'use()' are incompatible between these types.
33
Type 'PassportStatic' is not assignable to type 'this'.
4-
'this' could be instantiated with an arbitrary type which could be unrelated to 'PassportStatic'.
4+
'PassportStatic' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Passport'.
55

66

77
==== tests/cases/compiler/passport.d.ts (0 errors) ====
@@ -29,4 +29,4 @@ tests/cases/compiler/test.ts(4,5): error TS2322: Type 'PassportStatic' is not as
2929
!!! error TS2322: Type 'PassportStatic' is not assignable to type 'Passport'.
3030
!!! error TS2322: The types returned by 'use()' are incompatible between these types.
3131
!!! error TS2322: Type 'PassportStatic' is not assignable to type 'this'.
32-
!!! error TS2322: 'this' could be instantiated with an arbitrary type which could be unrelated to 'PassportStatic'.
32+
!!! error TS2322: 'PassportStatic' is assignable to the constraint of type 'this', but 'this' could be instantiated with a different subtype of constraint 'Passport'.

0 commit comments

Comments
 (0)