9b1718677a
* Support starting and middle rest elements in tuples * Accept new baselines * Include all rest arguments in error span * Accept new baselines * Fix tests * Add new tests * Fix lint errors
81 lines
3.5 KiB
Plaintext
81 lines
3.5 KiB
Plaintext
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(11,29): error TS1257: A required element cannot follow an optional element.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type 'T2' is not assignable to type 'T1'.
|
|
Source provides no match for required element at position 2 in target.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type 'T3' is not assignable to type 'T1'.
|
|
Source provides no match for required element at position 1 in target.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type 'T4' is not assignable to type 'T1'.
|
|
Source provides no match for required element at position 0 in target.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type 'T3' is not assignable to type 'T2'.
|
|
Source provides no match for required element at position 1 in target.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type 'T4' is not assignable to type 'T2'.
|
|
Source provides no match for required element at position 0 in target.
|
|
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type 'T4' is not assignable to type 'T3'.
|
|
Source provides no match for required element at position 0 in target.
|
|
|
|
|
|
==== tests/cases/conformance/types/tuple/optionalTupleElements1.ts (7 errors) ====
|
|
type T1 = [number, string, boolean];
|
|
type T2 = [number, string, boolean?];
|
|
type T3 = [number, string?, boolean?];
|
|
type T4 = [number?, string?, boolean?];
|
|
|
|
type L1 = T1["length"];
|
|
type L2 = T2["length"];
|
|
type L3 = T3["length"];
|
|
type L4 = T4["length"];
|
|
|
|
type T5 = [number, string?, boolean]; // Error
|
|
~~~~~~~
|
|
!!! error TS1257: A required element cannot follow an optional element.
|
|
|
|
function f1(t1: T1, t2: T2, t3: T3, t4: T4) {
|
|
t1 = t1;
|
|
t1 = t2; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T2' is not assignable to type 'T1'.
|
|
!!! error TS2322: Source provides no match for required element at position 2 in target.
|
|
t1 = t3; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T3' is not assignable to type 'T1'.
|
|
!!! error TS2322: Source provides no match for required element at position 1 in target.
|
|
t1 = t4; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T4' is not assignable to type 'T1'.
|
|
!!! error TS2322: Source provides no match for required element at position 0 in target.
|
|
t2 = t1;
|
|
t2 = t2;
|
|
t2 = t3; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T3' is not assignable to type 'T2'.
|
|
!!! error TS2322: Source provides no match for required element at position 1 in target.
|
|
t2 = t4; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T4' is not assignable to type 'T2'.
|
|
!!! error TS2322: Source provides no match for required element at position 0 in target.
|
|
t3 = t1;
|
|
t3 = t2;
|
|
t3 = t3;
|
|
t3 = t4; // Error
|
|
~~
|
|
!!! error TS2322: Type 'T4' is not assignable to type 'T3'.
|
|
!!! error TS2322: Source provides no match for required element at position 0 in target.
|
|
t4 = t1;
|
|
t4 = t2;
|
|
t4 = t3;
|
|
t4 = t4;
|
|
}
|
|
|
|
let t2: T2;
|
|
let t3: T3;
|
|
let t4: T4;
|
|
|
|
t2 = [42, "hello"];
|
|
t3 = [42, "hello"];
|
|
t3 = [42,,true]
|
|
t3 = [42];
|
|
t4 = [42, "hello"];
|
|
t4 = [42,,true];
|
|
t4 = [,"hello", true];
|
|
t4 = [,,true];
|
|
t4 = [];
|
|
|