mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Handle 'keyof' for generic tuple types (#39218)
* Handle keyof T where T is generic tuple type * Add tests * Accept new baselines * Address CR feedback * Accept new baselines
This commit is contained in:
parent
8df85b5cae
commit
ee4aee0531
@ -10195,7 +10195,8 @@ namespace ts {
|
||||
return type;
|
||||
}
|
||||
if (type.flags & TypeFlags.Index) {
|
||||
return getIndexType(getApparentType((<IndexType>type).type));
|
||||
const t = getApparentType((<IndexType>type).type);
|
||||
return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t);
|
||||
}
|
||||
if (type.flags & TypeFlags.Conditional) {
|
||||
if ((<ConditionalType>type).root.isDistributive) {
|
||||
@ -10520,9 +10521,6 @@ namespace ts {
|
||||
return indexedAccess;
|
||||
}
|
||||
}
|
||||
if (isGenericTupleType(type.objectType)) {
|
||||
return getIndexTypeOfType(type.objectType, IndexKind.Number);
|
||||
}
|
||||
const objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
|
||||
if (objectConstraint && objectConstraint !== type.objectType) {
|
||||
return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType);
|
||||
@ -10711,9 +10709,6 @@ namespace ts {
|
||||
return keyofConstraintType;
|
||||
}
|
||||
if (t.flags & TypeFlags.IndexedAccess) {
|
||||
if (isGenericTupleType((<IndexedAccessType>t).objectType)) {
|
||||
return getIndexTypeOfType((<IndexedAccessType>t).objectType, IndexKind.Number);
|
||||
}
|
||||
const baseObjectType = getBaseConstraint((<IndexedAccessType>t).objectType);
|
||||
const baseIndexType = getBaseConstraint((<IndexedAccessType>t).indexType);
|
||||
const baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType);
|
||||
@ -12647,6 +12642,11 @@ namespace ts {
|
||||
/*readonly*/ false, target.labeledElementDeclarations && target.labeledElementDeclarations.slice(index, endIndex));
|
||||
}
|
||||
|
||||
function getKnownKeysOfTupleType(type: TupleTypeReference) {
|
||||
return getUnionType(append(arrayOf(type.target.fixedLength, i => getLiteralType("" + i)),
|
||||
getIndexType(type.target.readonly ? globalReadonlyArrayType : globalArrayType)));
|
||||
}
|
||||
|
||||
function getTypeFromOptionalTypeNode(node: OptionalTypeNode): Type {
|
||||
const type = getTypeFromTypeNode(node.type);
|
||||
return strictNullChecks ? getOptionalType(type) : type;
|
||||
@ -16831,11 +16831,11 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
// For a generic type T, [...T] is assignable to T, T is assignable to readonly [...T], and T is assignable
|
||||
// to [...T] when T is constrained to a mutable array or tuple type.
|
||||
if (isSingleElementGenericTupleType(source) && getTypeArguments(source)[0] === target && !source.target.readonly ||
|
||||
isSingleElementGenericTupleType(target) && getTypeArguments(target)[0] === source && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source))) {
|
||||
return Ternary.True;
|
||||
// For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T],
|
||||
// and U is assignable to [...T] when U is constrained to a mutable array or tuple type.
|
||||
if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
|
||||
isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (target.flags & TypeFlags.TypeParameter) {
|
||||
@ -16851,22 +16851,32 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
else if (target.flags & TypeFlags.Index) {
|
||||
const targetType = (target as IndexType).type;
|
||||
// A keyof S is related to a keyof T if T is related to S.
|
||||
if (source.flags & TypeFlags.Index) {
|
||||
if (result = isRelatedTo((<IndexType>target).type, (<IndexType>source).type, /*reportErrors*/ false)) {
|
||||
if (result = isRelatedTo(targetType, (<IndexType>source).type, /*reportErrors*/ false)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
|
||||
// simplified form of T or, if T doesn't simplify, the constraint of T.
|
||||
const constraint = getSimplifiedTypeOrConstraint((<IndexType>target).type);
|
||||
if (constraint) {
|
||||
// We require Ternary.True here such that circular constraints don't cause
|
||||
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
||||
// 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
|
||||
// related to other types.
|
||||
if (isRelatedTo(source, getIndexType(constraint, (target as IndexType).stringsOnly), reportErrors) === Ternary.True) {
|
||||
return Ternary.True;
|
||||
if (isTupleType(targetType)) {
|
||||
// An index type can have a tuple type target when the tuple type contains variadic elements.
|
||||
// Check if the source is related to the known keys of the tuple type.
|
||||
if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType), reportErrors)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// A type S is assignable to keyof T if S is assignable to keyof C, where C is the
|
||||
// simplified form of T or, if T doesn't simplify, the constraint of T.
|
||||
const constraint = getSimplifiedTypeOrConstraint(targetType);
|
||||
if (constraint) {
|
||||
// We require Ternary.True here such that circular constraints don't cause
|
||||
// false positives. For example, given 'T extends { [K in keyof T]: string }',
|
||||
// 'keyof T' has itself as its constraint and produces a Ternary.Maybe when
|
||||
// related to other types.
|
||||
if (isRelatedTo(source, getIndexType(constraint, (target as IndexType).stringsOnly), reportErrors) === Ternary.True) {
|
||||
return Ternary.True;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +20,29 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(169,5): error TS2322: Typ
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(170,5): error TS2322: Type 'T' is not assignable to type '[...T]'.
|
||||
The type 'readonly unknown[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(171,5): error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(303,14): error TS7019: Rest parameter 'x' implicitly has an 'any[]' type.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(181,5): error TS2322: Type 'T' is not assignable to type '[...U]'.
|
||||
Type 'string[]' is not assignable to type '[...U]'.
|
||||
Target requires 1 element(s) but source may have fewer.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(182,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
|
||||
Type 'string[]' is not assignable to type 'U'.
|
||||
'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(188,5): error TS2322: Type 'T' is not assignable to type '[...T]'.
|
||||
The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(190,5): error TS2322: Type 'T' is not assignable to type '[...U]'.
|
||||
The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...U]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(191,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'.
|
||||
Type 'readonly string[]' is not assignable to type 'U'.
|
||||
'U' could be instantiated with an arbitrary type which could be unrelated to 'readonly string[]'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'.
|
||||
Type '"2"' is not assignable to type 'number | "0" | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" | "1"'.
|
||||
tests/cases/conformance/types/tuple/variadicTuples1.ts(333,14): error TS7019: Rest parameter 'x' implicitly has an 'any[]' type.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/tuple/variadicTuples1.ts (13 errors) ====
|
||||
==== tests/cases/conformance/types/tuple/variadicTuples1.ts (19 errors) ====
|
||||
// Variadics in tuple types
|
||||
|
||||
type TV0<T extends unknown[]> = [string, ...T];
|
||||
@ -234,6 +253,61 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(303,14): error TS7019: Re
|
||||
r = m;
|
||||
}
|
||||
|
||||
function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0;
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T' is not assignable to type '[...U]'.
|
||||
!!! error TS2322: Type 'string[]' is not assignable to type '[...U]'.
|
||||
!!! error TS2322: Target requires 1 element(s) but source may have fewer.
|
||||
t2 = t1; // Error
|
||||
~~
|
||||
!!! error TS2322: Type '[...T]' is not assignable to type '[...U]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'U'.
|
||||
!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'.
|
||||
!!! error TS2322: Type 'string[]' is not assignable to type 'U'.
|
||||
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'.
|
||||
}
|
||||
|
||||
function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T' is not assignable to type '[...T]'.
|
||||
!!! error TS2322: The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'.
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'T' is not assignable to type '[...U]'.
|
||||
!!! error TS2322: The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...U]'.
|
||||
t2 = t1; // Error
|
||||
~~
|
||||
!!! error TS2322: Type '[...T]' is not assignable to type '[...U]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'U'.
|
||||
!!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'.
|
||||
!!! error TS2322: Type 'readonly string[]' is not assignable to type 'U'.
|
||||
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'readonly string[]'.
|
||||
}
|
||||
|
||||
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
|
||||
k0 = 'length';
|
||||
k1 = 'length';
|
||||
k2 = 'length';
|
||||
k0 = 'slice';
|
||||
k1 = 'slice';
|
||||
k2 = 'slice';
|
||||
k3 = '0';
|
||||
k3 = '1';
|
||||
k3 = '2'; // Error
|
||||
~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'.
|
||||
!!! error TS2322: Type '"2"' is not assignable to type 'number | "0" | "length" | "toString" | "toLocaleString" | "pop" | "push" | "concat" | "join" | "reverse" | "shift" | "slice" | "sort" | "splice" | "unshift" | "indexOf" | "lastIndexOf" | "every" | "some" | "forEach" | "map" | "filter" | "reduce" | "reduceRight" | "1"'.
|
||||
}
|
||||
|
||||
// Inference between variadic tuple types
|
||||
|
||||
type First<T extends readonly unknown[]> = T[0];
|
||||
|
||||
@ -174,6 +174,36 @@ function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T])
|
||||
r = m;
|
||||
}
|
||||
|
||||
function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0;
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
|
||||
function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0; // Error
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
|
||||
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
|
||||
k0 = 'length';
|
||||
k1 = 'length';
|
||||
k2 = 'length';
|
||||
k0 = 'slice';
|
||||
k1 = 'slice';
|
||||
k2 = 'slice';
|
||||
k3 = '0';
|
||||
k3 = '1';
|
||||
k3 = '2'; // Error
|
||||
}
|
||||
|
||||
// Inference between variadic tuple types
|
||||
|
||||
type First<T extends readonly unknown[]> = T[0];
|
||||
@ -414,6 +444,33 @@ function f12(t, m, r) {
|
||||
r = t;
|
||||
r = m;
|
||||
}
|
||||
function f13(t0, t1, t2) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0;
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
function f14(t0, t1, t2) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0; // Error
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
function f15(k0, k1, k2, k3) {
|
||||
k0 = 'length';
|
||||
k1 = 'length';
|
||||
k2 = 'length';
|
||||
k0 = 'slice';
|
||||
k1 = 'slice';
|
||||
k2 = 'slice';
|
||||
k3 = '0';
|
||||
k3 = '1';
|
||||
k3 = '2'; // Error
|
||||
}
|
||||
// Inference to [...T, ...U] with implied arity for T
|
||||
function curry(f) {
|
||||
var a = [];
|
||||
@ -522,6 +579,9 @@ declare function gx2<U extends unknown[], V extends readonly unknown[]>(u: U, v:
|
||||
declare function f10<T extends string[], U extends T>(x: [string, ...unknown[]], y: [string, ...T], z: [string, ...U]): void;
|
||||
declare function f11<T extends unknown[]>(t: T, m: [...T], r: readonly [...T]): void;
|
||||
declare function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T]): void;
|
||||
declare function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]): void;
|
||||
declare function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]): void;
|
||||
declare function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]): void;
|
||||
declare type First<T extends readonly unknown[]> = T[0];
|
||||
declare type DropFirst<T extends readonly unknown[]> = T extends readonly [any, ...infer U] ? U : [...T];
|
||||
declare type Last<T extends readonly unknown[]> = T extends readonly [...infer _, infer U] ? U : undefined;
|
||||
|
||||
@ -573,455 +573,571 @@ function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T])
|
||||
>m : Symbol(m, Decl(variadicTuples1.ts, 166, 48))
|
||||
}
|
||||
|
||||
function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
>f13 : Symbol(f13, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 175, 13))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 175, 32))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 175, 13))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 175, 46))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 175, 13))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 175, 52))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 175, 13))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 175, 64))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 175, 32))
|
||||
|
||||
t0 = t1;
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 175, 46))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 175, 52))
|
||||
|
||||
t0 = t2;
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 175, 46))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 175, 64))
|
||||
|
||||
t1 = t0;
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 175, 52))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 175, 46))
|
||||
|
||||
t1 = t2;
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 175, 52))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 175, 64))
|
||||
|
||||
t2 = t0; // Error
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 175, 64))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 175, 46))
|
||||
|
||||
t2 = t1; // Error
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 175, 64))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 175, 52))
|
||||
}
|
||||
|
||||
function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
>f14 : Symbol(f14, Decl(variadicTuples1.ts, 182, 1))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 184, 13))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 184, 41))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 184, 13))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 184, 55))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 184, 13))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 184, 61))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 184, 13))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 184, 73))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 184, 41))
|
||||
|
||||
t0 = t1;
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 184, 55))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 184, 61))
|
||||
|
||||
t0 = t2;
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 184, 55))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 184, 73))
|
||||
|
||||
t1 = t0; // Error
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 184, 61))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 184, 55))
|
||||
|
||||
t1 = t2;
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 184, 61))
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 184, 73))
|
||||
|
||||
t2 = t0; // Error
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 184, 73))
|
||||
>t0 : Symbol(t0, Decl(variadicTuples1.ts, 184, 55))
|
||||
|
||||
t2 = t1; // Error
|
||||
>t2 : Symbol(t2, Decl(variadicTuples1.ts, 184, 73))
|
||||
>t1 : Symbol(t1, Decl(variadicTuples1.ts, 184, 61))
|
||||
}
|
||||
|
||||
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
|
||||
>f15 : Symbol(f15, Decl(variadicTuples1.ts, 191, 1))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 193, 13))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 193, 32))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 193, 13))
|
||||
>k0 : Symbol(k0, Decl(variadicTuples1.ts, 193, 46))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 193, 13))
|
||||
>k1 : Symbol(k1, Decl(variadicTuples1.ts, 193, 58))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 193, 13))
|
||||
>k2 : Symbol(k2, Decl(variadicTuples1.ts, 193, 76))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 193, 32))
|
||||
>k3 : Symbol(k3, Decl(variadicTuples1.ts, 193, 94))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 193, 13))
|
||||
|
||||
k0 = 'length';
|
||||
>k0 : Symbol(k0, Decl(variadicTuples1.ts, 193, 46))
|
||||
|
||||
k1 = 'length';
|
||||
>k1 : Symbol(k1, Decl(variadicTuples1.ts, 193, 58))
|
||||
|
||||
k2 = 'length';
|
||||
>k2 : Symbol(k2, Decl(variadicTuples1.ts, 193, 76))
|
||||
|
||||
k0 = 'slice';
|
||||
>k0 : Symbol(k0, Decl(variadicTuples1.ts, 193, 46))
|
||||
|
||||
k1 = 'slice';
|
||||
>k1 : Symbol(k1, Decl(variadicTuples1.ts, 193, 58))
|
||||
|
||||
k2 = 'slice';
|
||||
>k2 : Symbol(k2, Decl(variadicTuples1.ts, 193, 76))
|
||||
|
||||
k3 = '0';
|
||||
>k3 : Symbol(k3, Decl(variadicTuples1.ts, 193, 94))
|
||||
|
||||
k3 = '1';
|
||||
>k3 : Symbol(k3, Decl(variadicTuples1.ts, 193, 94))
|
||||
|
||||
k3 = '2'; // Error
|
||||
>k3 : Symbol(k3, Decl(variadicTuples1.ts, 193, 94))
|
||||
}
|
||||
|
||||
// Inference between variadic tuple types
|
||||
|
||||
type First<T extends readonly unknown[]> = T[0];
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 177, 11))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 177, 11))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 207, 11))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 207, 11))
|
||||
|
||||
type DropFirst<T extends readonly unknown[]> = T extends readonly [any, ...infer U] ? U : [...T];
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 178, 15))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 178, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 178, 80))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 178, 80))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 178, 15))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 208, 15))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 208, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 208, 80))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 208, 80))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 208, 15))
|
||||
|
||||
type Last<T extends readonly unknown[]> = T extends readonly [...infer _, infer U] ? U : undefined;
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 180, 10))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 180, 10))
|
||||
>_ : Symbol(_, Decl(variadicTuples1.ts, 180, 70))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 180, 79))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 180, 79))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 210, 10))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 210, 10))
|
||||
>_ : Symbol(_, Decl(variadicTuples1.ts, 210, 70))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 210, 79))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 210, 79))
|
||||
|
||||
type DropLast<T extends readonly unknown[]> = T extends readonly [...infer U, any] ? U : [...T];
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 181, 14))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 181, 14))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 181, 74))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 181, 74))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 181, 14))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 211, 14))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 211, 14))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 211, 74))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 211, 74))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 211, 14))
|
||||
|
||||
type T00 = First<[number, symbol, string]>;
|
||||
>T00 : Symbol(T00, Decl(variadicTuples1.ts, 181, 96))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T00 : Symbol(T00, Decl(variadicTuples1.ts, 211, 96))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T01 = First<[symbol, string]>;
|
||||
>T01 : Symbol(T01, Decl(variadicTuples1.ts, 183, 43))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T01 : Symbol(T01, Decl(variadicTuples1.ts, 213, 43))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T02 = First<[string]>;
|
||||
>T02 : Symbol(T02, Decl(variadicTuples1.ts, 184, 35))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T02 : Symbol(T02, Decl(variadicTuples1.ts, 214, 35))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T03 = First<[number, symbol, ...string[]]>;
|
||||
>T03 : Symbol(T03, Decl(variadicTuples1.ts, 185, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T03 : Symbol(T03, Decl(variadicTuples1.ts, 215, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T04 = First<[symbol, ...string[]]>;
|
||||
>T04 : Symbol(T04, Decl(variadicTuples1.ts, 186, 48))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T04 : Symbol(T04, Decl(variadicTuples1.ts, 216, 48))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T05 = First<string[]>;
|
||||
>T05 : Symbol(T05, Decl(variadicTuples1.ts, 187, 40))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T05 : Symbol(T05, Decl(variadicTuples1.ts, 217, 40))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T06 = First<[]>;
|
||||
>T06 : Symbol(T06, Decl(variadicTuples1.ts, 188, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T06 : Symbol(T06, Decl(variadicTuples1.ts, 218, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T07 = First<any>;
|
||||
>T07 : Symbol(T07, Decl(variadicTuples1.ts, 189, 21))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T07 : Symbol(T07, Decl(variadicTuples1.ts, 219, 21))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T08 = First<never>;
|
||||
>T08 : Symbol(T08, Decl(variadicTuples1.ts, 190, 22))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>T08 : Symbol(T08, Decl(variadicTuples1.ts, 220, 22))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type T10 = DropFirst<[number, symbol, string]>;
|
||||
>T10 : Symbol(T10, Decl(variadicTuples1.ts, 191, 24))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T10 : Symbol(T10, Decl(variadicTuples1.ts, 221, 24))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T11 = DropFirst<[symbol, string]>;
|
||||
>T11 : Symbol(T11, Decl(variadicTuples1.ts, 193, 47))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T11 : Symbol(T11, Decl(variadicTuples1.ts, 223, 47))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T12 = DropFirst<[string]>;
|
||||
>T12 : Symbol(T12, Decl(variadicTuples1.ts, 194, 39))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T12 : Symbol(T12, Decl(variadicTuples1.ts, 224, 39))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T13 = DropFirst<[number, symbol, ...string[]]>;
|
||||
>T13 : Symbol(T13, Decl(variadicTuples1.ts, 195, 31))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T13 : Symbol(T13, Decl(variadicTuples1.ts, 225, 31))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T14 = DropFirst<[symbol, ...string[]]>;
|
||||
>T14 : Symbol(T14, Decl(variadicTuples1.ts, 196, 52))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T14 : Symbol(T14, Decl(variadicTuples1.ts, 226, 52))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T15 = DropFirst<string[]>;
|
||||
>T15 : Symbol(T15, Decl(variadicTuples1.ts, 197, 44))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T15 : Symbol(T15, Decl(variadicTuples1.ts, 227, 44))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T16 = DropFirst<[]>;
|
||||
>T16 : Symbol(T16, Decl(variadicTuples1.ts, 198, 31))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T16 : Symbol(T16, Decl(variadicTuples1.ts, 228, 31))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T17 = DropFirst<any>;
|
||||
>T17 : Symbol(T17, Decl(variadicTuples1.ts, 199, 25))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T17 : Symbol(T17, Decl(variadicTuples1.ts, 229, 25))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T18 = DropFirst<never>;
|
||||
>T18 : Symbol(T18, Decl(variadicTuples1.ts, 200, 26))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>T18 : Symbol(T18, Decl(variadicTuples1.ts, 230, 26))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type T20 = Last<[number, symbol, string]>;
|
||||
>T20 : Symbol(T20, Decl(variadicTuples1.ts, 201, 28))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T20 : Symbol(T20, Decl(variadicTuples1.ts, 231, 28))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T21 = Last<[symbol, string]>;
|
||||
>T21 : Symbol(T21, Decl(variadicTuples1.ts, 203, 42))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T21 : Symbol(T21, Decl(variadicTuples1.ts, 233, 42))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T22 = Last<[string]>;
|
||||
>T22 : Symbol(T22, Decl(variadicTuples1.ts, 204, 34))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T22 : Symbol(T22, Decl(variadicTuples1.ts, 234, 34))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T23 = Last<[number, symbol, ...string[]]>;
|
||||
>T23 : Symbol(T23, Decl(variadicTuples1.ts, 205, 26))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T23 : Symbol(T23, Decl(variadicTuples1.ts, 235, 26))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T24 = Last<[symbol, ...string[]]>;
|
||||
>T24 : Symbol(T24, Decl(variadicTuples1.ts, 206, 47))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T24 : Symbol(T24, Decl(variadicTuples1.ts, 236, 47))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T25 = Last<string[]>;
|
||||
>T25 : Symbol(T25, Decl(variadicTuples1.ts, 207, 39))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T25 : Symbol(T25, Decl(variadicTuples1.ts, 237, 39))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T26 = Last<[]>; // unknown[], maybe should be []
|
||||
>T26 : Symbol(T26, Decl(variadicTuples1.ts, 208, 26))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T26 : Symbol(T26, Decl(variadicTuples1.ts, 238, 26))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T27 = Last<any>; // unknown, maybe should be any
|
||||
>T27 : Symbol(T27, Decl(variadicTuples1.ts, 209, 20))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T27 : Symbol(T27, Decl(variadicTuples1.ts, 239, 20))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T28 = Last<never>;
|
||||
>T28 : Symbol(T28, Decl(variadicTuples1.ts, 210, 21))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>T28 : Symbol(T28, Decl(variadicTuples1.ts, 240, 21))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type T30 = DropLast<[number, symbol, string]>;
|
||||
>T30 : Symbol(T30, Decl(variadicTuples1.ts, 211, 23))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T30 : Symbol(T30, Decl(variadicTuples1.ts, 241, 23))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T31 = DropLast<[symbol, string]>;
|
||||
>T31 : Symbol(T31, Decl(variadicTuples1.ts, 213, 46))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T31 : Symbol(T31, Decl(variadicTuples1.ts, 243, 46))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T32 = DropLast<[string]>;
|
||||
>T32 : Symbol(T32, Decl(variadicTuples1.ts, 214, 38))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T32 : Symbol(T32, Decl(variadicTuples1.ts, 244, 38))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T33 = DropLast<[number, symbol, ...string[]]>;
|
||||
>T33 : Symbol(T33, Decl(variadicTuples1.ts, 215, 30))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T33 : Symbol(T33, Decl(variadicTuples1.ts, 245, 30))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T34 = DropLast<[symbol, ...string[]]>;
|
||||
>T34 : Symbol(T34, Decl(variadicTuples1.ts, 216, 51))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T34 : Symbol(T34, Decl(variadicTuples1.ts, 246, 51))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T35 = DropLast<string[]>;
|
||||
>T35 : Symbol(T35, Decl(variadicTuples1.ts, 217, 43))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T35 : Symbol(T35, Decl(variadicTuples1.ts, 247, 43))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T36 = DropLast<[]>; // unknown[], maybe should be []
|
||||
>T36 : Symbol(T36, Decl(variadicTuples1.ts, 218, 30))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T36 : Symbol(T36, Decl(variadicTuples1.ts, 248, 30))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T37 = DropLast<any>;
|
||||
>T37 : Symbol(T37, Decl(variadicTuples1.ts, 219, 24))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T37 : Symbol(T37, Decl(variadicTuples1.ts, 249, 24))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type T38 = DropLast<never>;
|
||||
>T38 : Symbol(T38, Decl(variadicTuples1.ts, 220, 25))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>T38 : Symbol(T38, Decl(variadicTuples1.ts, 250, 25))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R00 = First<readonly [number, symbol, string]>;
|
||||
>R00 : Symbol(R00, Decl(variadicTuples1.ts, 221, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R00 : Symbol(R00, Decl(variadicTuples1.ts, 251, 27))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R01 = First<readonly [symbol, string]>;
|
||||
>R01 : Symbol(R01, Decl(variadicTuples1.ts, 223, 52))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R01 : Symbol(R01, Decl(variadicTuples1.ts, 253, 52))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R02 = First<readonly [string]>;
|
||||
>R02 : Symbol(R02, Decl(variadicTuples1.ts, 224, 44))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R02 : Symbol(R02, Decl(variadicTuples1.ts, 254, 44))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R03 = First<readonly [number, symbol, ...string[]]>;
|
||||
>R03 : Symbol(R03, Decl(variadicTuples1.ts, 225, 36))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R03 : Symbol(R03, Decl(variadicTuples1.ts, 255, 36))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R04 = First<readonly [symbol, ...string[]]>;
|
||||
>R04 : Symbol(R04, Decl(variadicTuples1.ts, 226, 57))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R04 : Symbol(R04, Decl(variadicTuples1.ts, 256, 57))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R05 = First<readonly string[]>;
|
||||
>R05 : Symbol(R05, Decl(variadicTuples1.ts, 227, 49))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R05 : Symbol(R05, Decl(variadicTuples1.ts, 257, 49))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R06 = First<readonly []>;
|
||||
>R06 : Symbol(R06, Decl(variadicTuples1.ts, 228, 36))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 173, 1))
|
||||
>R06 : Symbol(R06, Decl(variadicTuples1.ts, 258, 36))
|
||||
>First : Symbol(First, Decl(variadicTuples1.ts, 203, 1))
|
||||
|
||||
type R10 = DropFirst<readonly [number, symbol, string]>;
|
||||
>R10 : Symbol(R10, Decl(variadicTuples1.ts, 229, 30))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R10 : Symbol(R10, Decl(variadicTuples1.ts, 259, 30))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R11 = DropFirst<readonly [symbol, string]>;
|
||||
>R11 : Symbol(R11, Decl(variadicTuples1.ts, 231, 56))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R11 : Symbol(R11, Decl(variadicTuples1.ts, 261, 56))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R12 = DropFirst<readonly [string]>;
|
||||
>R12 : Symbol(R12, Decl(variadicTuples1.ts, 232, 48))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R12 : Symbol(R12, Decl(variadicTuples1.ts, 262, 48))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R13 = DropFirst<readonly [number, symbol, ...string[]]>;
|
||||
>R13 : Symbol(R13, Decl(variadicTuples1.ts, 233, 40))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R13 : Symbol(R13, Decl(variadicTuples1.ts, 263, 40))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R14 = DropFirst<readonly [symbol, ...string[]]>;
|
||||
>R14 : Symbol(R14, Decl(variadicTuples1.ts, 234, 61))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R14 : Symbol(R14, Decl(variadicTuples1.ts, 264, 61))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R15 = DropFirst<readonly string[]>;
|
||||
>R15 : Symbol(R15, Decl(variadicTuples1.ts, 235, 53))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R15 : Symbol(R15, Decl(variadicTuples1.ts, 265, 53))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R16 = DropFirst<readonly []>;
|
||||
>R16 : Symbol(R16, Decl(variadicTuples1.ts, 236, 40))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 177, 48))
|
||||
>R16 : Symbol(R16, Decl(variadicTuples1.ts, 266, 40))
|
||||
>DropFirst : Symbol(DropFirst, Decl(variadicTuples1.ts, 207, 48))
|
||||
|
||||
type R20 = Last<readonly [number, symbol, string]>;
|
||||
>R20 : Symbol(R20, Decl(variadicTuples1.ts, 237, 34))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R20 : Symbol(R20, Decl(variadicTuples1.ts, 267, 34))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R21 = Last<readonly [symbol, string]>;
|
||||
>R21 : Symbol(R21, Decl(variadicTuples1.ts, 239, 51))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R21 : Symbol(R21, Decl(variadicTuples1.ts, 269, 51))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R22 = Last<readonly [string]>;
|
||||
>R22 : Symbol(R22, Decl(variadicTuples1.ts, 240, 43))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R22 : Symbol(R22, Decl(variadicTuples1.ts, 270, 43))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R23 = Last<readonly [number, symbol, ...string[]]>;
|
||||
>R23 : Symbol(R23, Decl(variadicTuples1.ts, 241, 35))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R23 : Symbol(R23, Decl(variadicTuples1.ts, 271, 35))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R24 = Last<readonly [symbol, ...string[]]>;
|
||||
>R24 : Symbol(R24, Decl(variadicTuples1.ts, 242, 56))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R24 : Symbol(R24, Decl(variadicTuples1.ts, 272, 56))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R25 = Last<readonly string[]>;
|
||||
>R25 : Symbol(R25, Decl(variadicTuples1.ts, 243, 48))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R25 : Symbol(R25, Decl(variadicTuples1.ts, 273, 48))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R26 = Last<readonly []>;
|
||||
>R26 : Symbol(R26, Decl(variadicTuples1.ts, 244, 35))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 178, 97))
|
||||
>R26 : Symbol(R26, Decl(variadicTuples1.ts, 274, 35))
|
||||
>Last : Symbol(Last, Decl(variadicTuples1.ts, 208, 97))
|
||||
|
||||
type R30 = DropLast<readonly [number, symbol, string]>;
|
||||
>R30 : Symbol(R30, Decl(variadicTuples1.ts, 245, 29))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R30 : Symbol(R30, Decl(variadicTuples1.ts, 275, 29))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R31 = DropLast<readonly [symbol, string]>;
|
||||
>R31 : Symbol(R31, Decl(variadicTuples1.ts, 247, 55))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R31 : Symbol(R31, Decl(variadicTuples1.ts, 277, 55))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R32 = DropLast<readonly [string]>;
|
||||
>R32 : Symbol(R32, Decl(variadicTuples1.ts, 248, 47))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R32 : Symbol(R32, Decl(variadicTuples1.ts, 278, 47))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R33 = DropLast<readonly [number, symbol, ...string[]]>;
|
||||
>R33 : Symbol(R33, Decl(variadicTuples1.ts, 249, 39))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R33 : Symbol(R33, Decl(variadicTuples1.ts, 279, 39))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R34 = DropLast<readonly [symbol, ...string[]]>;
|
||||
>R34 : Symbol(R34, Decl(variadicTuples1.ts, 250, 60))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R34 : Symbol(R34, Decl(variadicTuples1.ts, 280, 60))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R35 = DropLast<readonly string[]>;
|
||||
>R35 : Symbol(R35, Decl(variadicTuples1.ts, 251, 52))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R35 : Symbol(R35, Decl(variadicTuples1.ts, 281, 52))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
type R36 = DropLast<readonly []>;
|
||||
>R36 : Symbol(R36, Decl(variadicTuples1.ts, 252, 39))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 180, 99))
|
||||
>R36 : Symbol(R36, Decl(variadicTuples1.ts, 282, 39))
|
||||
>DropLast : Symbol(DropLast, Decl(variadicTuples1.ts, 210, 99))
|
||||
|
||||
// Inference to [...T, ...U] with implied arity for T
|
||||
|
||||
function curry<T extends unknown[], U extends unknown[], R>(f: (...args: [...T, ...U]) => R, ...a: T) {
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 257, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 257, 35))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 257, 56))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 257, 60))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 257, 64))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 257, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 257, 35))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 257, 56))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 257, 92))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 257, 15))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 287, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 287, 35))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 287, 56))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 287, 60))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 287, 64))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 287, 15))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 287, 35))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 287, 56))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 287, 92))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 287, 15))
|
||||
|
||||
return (...b: U) => f(...a, ...b);
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 258, 12))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 257, 35))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 257, 60))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 257, 92))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 258, 12))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 288, 12))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 287, 35))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 287, 60))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 287, 92))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 288, 12))
|
||||
}
|
||||
|
||||
const fn1 = (a: number, b: string, c: boolean, d: string[]) => 0;
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 261, 13))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 261, 23))
|
||||
>c : Symbol(c, Decl(variadicTuples1.ts, 261, 34))
|
||||
>d : Symbol(d, Decl(variadicTuples1.ts, 261, 46))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 291, 13))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 291, 23))
|
||||
>c : Symbol(c, Decl(variadicTuples1.ts, 291, 34))
|
||||
>d : Symbol(d, Decl(variadicTuples1.ts, 291, 46))
|
||||
|
||||
const c0 = curry(fn1); // (a: number, b: string, c: boolean, d: string[]) => number
|
||||
>c0 : Symbol(c0, Decl(variadicTuples1.ts, 263, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>c0 : Symbol(c0, Decl(variadicTuples1.ts, 293, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
|
||||
const c1 = curry(fn1, 1); // (b: string, c: boolean, d: string[]) => number
|
||||
>c1 : Symbol(c1, Decl(variadicTuples1.ts, 264, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>c1 : Symbol(c1, Decl(variadicTuples1.ts, 294, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
|
||||
const c2 = curry(fn1, 1, 'abc'); // (c: boolean, d: string[]) => number
|
||||
>c2 : Symbol(c2, Decl(variadicTuples1.ts, 265, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>c2 : Symbol(c2, Decl(variadicTuples1.ts, 295, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
|
||||
const c3 = curry(fn1, 1, 'abc', true); // (d: string[]) => number
|
||||
>c3 : Symbol(c3, Decl(variadicTuples1.ts, 266, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>c3 : Symbol(c3, Decl(variadicTuples1.ts, 296, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
|
||||
const c4 = curry(fn1, 1, 'abc', true, ['x', 'y']); // () => number
|
||||
>c4 : Symbol(c4, Decl(variadicTuples1.ts, 267, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 261, 5))
|
||||
>c4 : Symbol(c4, Decl(variadicTuples1.ts, 297, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn1 : Symbol(fn1, Decl(variadicTuples1.ts, 291, 5))
|
||||
|
||||
const fn2 = (x: number, b: boolean, ...args: string[]) => 0;
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 269, 5))
|
||||
>x : Symbol(x, Decl(variadicTuples1.ts, 269, 13))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 269, 23))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 269, 35))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 299, 5))
|
||||
>x : Symbol(x, Decl(variadicTuples1.ts, 299, 13))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 299, 23))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 299, 35))
|
||||
|
||||
const c10 = curry(fn2); // (x: number, b: boolean, ...args: string[]) => number
|
||||
>c10 : Symbol(c10, Decl(variadicTuples1.ts, 271, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 269, 5))
|
||||
>c10 : Symbol(c10, Decl(variadicTuples1.ts, 301, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 299, 5))
|
||||
|
||||
const c11 = curry(fn2, 1); // (b: boolean, ...args: string[]) => number
|
||||
>c11 : Symbol(c11, Decl(variadicTuples1.ts, 272, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 269, 5))
|
||||
>c11 : Symbol(c11, Decl(variadicTuples1.ts, 302, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 299, 5))
|
||||
|
||||
const c12 = curry(fn2, 1, true); // (...args: string[]) => number
|
||||
>c12 : Symbol(c12, Decl(variadicTuples1.ts, 273, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 269, 5))
|
||||
>c12 : Symbol(c12, Decl(variadicTuples1.ts, 303, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 299, 5))
|
||||
|
||||
const c13 = curry(fn2, 1, true, 'abc', 'def'); // (...args: string[]) => number
|
||||
>c13 : Symbol(c13, Decl(variadicTuples1.ts, 274, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 269, 5))
|
||||
>c13 : Symbol(c13, Decl(variadicTuples1.ts, 304, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn2 : Symbol(fn2, Decl(variadicTuples1.ts, 299, 5))
|
||||
|
||||
const fn3 = (...args: string[]) => 0;
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 276, 5))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 276, 13))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 306, 5))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 306, 13))
|
||||
|
||||
const c20 = curry(fn3); // (...args: string[]) => number
|
||||
>c20 : Symbol(c20, Decl(variadicTuples1.ts, 278, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 276, 5))
|
||||
>c20 : Symbol(c20, Decl(variadicTuples1.ts, 308, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 306, 5))
|
||||
|
||||
const c21 = curry(fn3, 'abc', 'def'); // (...args: string[]) => number
|
||||
>c21 : Symbol(c21, Decl(variadicTuples1.ts, 279, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 276, 5))
|
||||
>c21 : Symbol(c21, Decl(variadicTuples1.ts, 309, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 306, 5))
|
||||
|
||||
const c22 = curry(fn3, ...sa); // (...args: string[]) => number
|
||||
>c22 : Symbol(c22, Decl(variadicTuples1.ts, 280, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 253, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 276, 5))
|
||||
>c22 : Symbol(c22, Decl(variadicTuples1.ts, 310, 5))
|
||||
>curry : Symbol(curry, Decl(variadicTuples1.ts, 283, 33))
|
||||
>fn3 : Symbol(fn3, Decl(variadicTuples1.ts, 306, 5))
|
||||
>sa : Symbol(sa, Decl(variadicTuples1.ts, 29, 13))
|
||||
|
||||
// No inference to [...T, ...U] when there is no implied arity
|
||||
|
||||
function curry2<T extends unknown[], U extends unknown[], R>(f: (...args: [...T, ...U]) => R, t: [...T], u: [...U]) {
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 280, 30))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 284, 16))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 284, 36))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 284, 57))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 284, 61))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 284, 65))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 284, 16))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 284, 36))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 284, 57))
|
||||
>t : Symbol(t, Decl(variadicTuples1.ts, 284, 93))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 284, 16))
|
||||
>u : Symbol(u, Decl(variadicTuples1.ts, 284, 104))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 284, 36))
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 310, 30))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 314, 16))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 314, 36))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 314, 57))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 314, 61))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 314, 65))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 314, 16))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 314, 36))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 314, 57))
|
||||
>t : Symbol(t, Decl(variadicTuples1.ts, 314, 93))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 314, 16))
|
||||
>u : Symbol(u, Decl(variadicTuples1.ts, 314, 104))
|
||||
>U : Symbol(U, Decl(variadicTuples1.ts, 314, 36))
|
||||
|
||||
return f(...t, ...u);
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 284, 61))
|
||||
>t : Symbol(t, Decl(variadicTuples1.ts, 284, 93))
|
||||
>u : Symbol(u, Decl(variadicTuples1.ts, 284, 104))
|
||||
>f : Symbol(f, Decl(variadicTuples1.ts, 314, 61))
|
||||
>t : Symbol(t, Decl(variadicTuples1.ts, 314, 93))
|
||||
>u : Symbol(u, Decl(variadicTuples1.ts, 314, 104))
|
||||
}
|
||||
|
||||
declare function fn10(a: string, b: number, c: boolean): string[];
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 286, 1))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 288, 22))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 288, 32))
|
||||
>c : Symbol(c, Decl(variadicTuples1.ts, 288, 43))
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 316, 1))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 318, 22))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 318, 32))
|
||||
>c : Symbol(c, Decl(variadicTuples1.ts, 318, 43))
|
||||
|
||||
curry2(fn10, ['hello', 42], [true]);
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 280, 30))
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 286, 1))
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 310, 30))
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 316, 1))
|
||||
|
||||
curry2(fn10, ['hello'], [42, true]);
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 280, 30))
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 286, 1))
|
||||
>curry2 : Symbol(curry2, Decl(variadicTuples1.ts, 310, 30))
|
||||
>fn10 : Symbol(fn10, Decl(variadicTuples1.ts, 316, 1))
|
||||
|
||||
// Last argument is contextually typed
|
||||
|
||||
declare function call<T extends unknown[], R>(...args: [...T, (...args: T) => R]): [T, R];
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 291, 36))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 295, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 295, 42))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 295, 46))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 295, 22))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 295, 63))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 295, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 295, 42))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 295, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 295, 42))
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 321, 36))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 325, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 325, 42))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 325, 46))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 325, 22))
|
||||
>args : Symbol(args, Decl(variadicTuples1.ts, 325, 63))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 325, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 325, 42))
|
||||
>T : Symbol(T, Decl(variadicTuples1.ts, 325, 22))
|
||||
>R : Symbol(R, Decl(variadicTuples1.ts, 325, 42))
|
||||
|
||||
call('hello', 32, (a, b) => 42);
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 291, 36))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 297, 19))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 297, 21))
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 321, 36))
|
||||
>a : Symbol(a, Decl(variadicTuples1.ts, 327, 19))
|
||||
>b : Symbol(b, Decl(variadicTuples1.ts, 327, 21))
|
||||
|
||||
// Would be nice to infer [...string[], (...args: string[]) => number] here
|
||||
// Requires [starting-fixed-part, ...rest-part, ending-fixed-part] tuple structure
|
||||
|
||||
call(...sa, (...x) => 42);
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 291, 36))
|
||||
>call : Symbol(call, Decl(variadicTuples1.ts, 321, 36))
|
||||
>sa : Symbol(sa, Decl(variadicTuples1.ts, 29, 13))
|
||||
>x : Symbol(x, Decl(variadicTuples1.ts, 302, 13))
|
||||
>x : Symbol(x, Decl(variadicTuples1.ts, 332, 13))
|
||||
|
||||
|
||||
@ -643,6 +643,133 @@ function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T])
|
||||
>m : [...T]
|
||||
}
|
||||
|
||||
function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
>f13 : <T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) => void
|
||||
>t0 : T
|
||||
>t1 : [...T]
|
||||
>t2 : [...U]
|
||||
|
||||
t0 = t1;
|
||||
>t0 = t1 : [...T]
|
||||
>t0 : T
|
||||
>t1 : [...T]
|
||||
|
||||
t0 = t2;
|
||||
>t0 = t2 : [...U]
|
||||
>t0 : T
|
||||
>t2 : [...U]
|
||||
|
||||
t1 = t0;
|
||||
>t1 = t0 : T
|
||||
>t1 : [...T]
|
||||
>t0 : T
|
||||
|
||||
t1 = t2;
|
||||
>t1 = t2 : [...U]
|
||||
>t1 : [...T]
|
||||
>t2 : [...U]
|
||||
|
||||
t2 = t0; // Error
|
||||
>t2 = t0 : T
|
||||
>t2 : [...U]
|
||||
>t0 : T
|
||||
|
||||
t2 = t1; // Error
|
||||
>t2 = t1 : [...T]
|
||||
>t2 : [...U]
|
||||
>t1 : [...T]
|
||||
}
|
||||
|
||||
function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
>f14 : <T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) => void
|
||||
>t0 : T
|
||||
>t1 : [...T]
|
||||
>t2 : [...U]
|
||||
|
||||
t0 = t1;
|
||||
>t0 = t1 : [...T]
|
||||
>t0 : T
|
||||
>t1 : [...T]
|
||||
|
||||
t0 = t2;
|
||||
>t0 = t2 : [...U]
|
||||
>t0 : T
|
||||
>t2 : [...U]
|
||||
|
||||
t1 = t0; // Error
|
||||
>t1 = t0 : T
|
||||
>t1 : [...T]
|
||||
>t0 : T
|
||||
|
||||
t1 = t2;
|
||||
>t1 = t2 : [...U]
|
||||
>t1 : [...T]
|
||||
>t2 : [...U]
|
||||
|
||||
t2 = t0; // Error
|
||||
>t2 = t0 : T
|
||||
>t2 : [...U]
|
||||
>t0 : T
|
||||
|
||||
t2 = t1; // Error
|
||||
>t2 = t1 : [...T]
|
||||
>t2 : [...U]
|
||||
>t1 : [...T]
|
||||
}
|
||||
|
||||
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
|
||||
>f15 : <T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) => void
|
||||
>k0 : keyof T
|
||||
>k1 : keyof [...T]
|
||||
>k2 : keyof [...U]
|
||||
>k3 : keyof [1, 2, ...T]
|
||||
|
||||
k0 = 'length';
|
||||
>k0 = 'length' : "length"
|
||||
>k0 : keyof T
|
||||
>'length' : "length"
|
||||
|
||||
k1 = 'length';
|
||||
>k1 = 'length' : "length"
|
||||
>k1 : keyof [...T]
|
||||
>'length' : "length"
|
||||
|
||||
k2 = 'length';
|
||||
>k2 = 'length' : "length"
|
||||
>k2 : keyof [...U]
|
||||
>'length' : "length"
|
||||
|
||||
k0 = 'slice';
|
||||
>k0 = 'slice' : "slice"
|
||||
>k0 : keyof T
|
||||
>'slice' : "slice"
|
||||
|
||||
k1 = 'slice';
|
||||
>k1 = 'slice' : "slice"
|
||||
>k1 : keyof [...T]
|
||||
>'slice' : "slice"
|
||||
|
||||
k2 = 'slice';
|
||||
>k2 = 'slice' : "slice"
|
||||
>k2 : keyof [...U]
|
||||
>'slice' : "slice"
|
||||
|
||||
k3 = '0';
|
||||
>k3 = '0' : "0"
|
||||
>k3 : keyof [1, 2, ...T]
|
||||
>'0' : "0"
|
||||
|
||||
k3 = '1';
|
||||
>k3 = '1' : "1"
|
||||
>k3 : keyof [1, 2, ...T]
|
||||
>'1' : "1"
|
||||
|
||||
k3 = '2'; // Error
|
||||
>k3 = '2' : "2"
|
||||
>k3 : keyof [1, 2, ...T]
|
||||
>'2' : "2"
|
||||
}
|
||||
|
||||
// Inference between variadic tuple types
|
||||
|
||||
type First<T extends readonly unknown[]> = T[0];
|
||||
|
||||
@ -176,6 +176,36 @@ function f12<T extends readonly unknown[]>(t: T, m: [...T], r: readonly [...T])
|
||||
r = m;
|
||||
}
|
||||
|
||||
function f13<T extends string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0;
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
|
||||
function f14<T extends readonly string[], U extends T>(t0: T, t1: [...T], t2: [...U]) {
|
||||
t0 = t1;
|
||||
t0 = t2;
|
||||
t1 = t0; // Error
|
||||
t1 = t2;
|
||||
t2 = t0; // Error
|
||||
t2 = t1; // Error
|
||||
}
|
||||
|
||||
function f15<T extends string[], U extends T>(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) {
|
||||
k0 = 'length';
|
||||
k1 = 'length';
|
||||
k2 = 'length';
|
||||
k0 = 'slice';
|
||||
k1 = 'slice';
|
||||
k2 = 'slice';
|
||||
k3 = '0';
|
||||
k3 = '1';
|
||||
k3 = '2'; // Error
|
||||
}
|
||||
|
||||
// Inference between variadic tuple types
|
||||
|
||||
type First<T extends readonly unknown[]> = T[0];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user