Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Nov 13, 2020
commit c9b8bd1f492c541cdb77d7582a8a770bbd0a12b8
5 changes: 4 additions & 1 deletion tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,10 @@ declare namespace ts {
Optional = 2,
Rest = 4,
Variadic = 8,
Variable = 12
Fixed = 3,
Variable = 12,
NonRequired = 14,
NonRest = 11
}
export interface TupleType extends GenericType {
elementFlags: readonly ElementFlags[];
Expand Down
5 changes: 4 additions & 1 deletion tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2590,7 +2590,10 @@ declare namespace ts {
Optional = 2,
Rest = 4,
Variadic = 8,
Variable = 12
Fixed = 3,
Variable = 12,
NonRequired = 14,
NonRest = 11
}
export interface TupleType extends GenericType {
elementFlags: readonly ElementFlags[];
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/for-of39.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
Types of property '1' are incompatible.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'number' is not assignable to type 'boolean'.
Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
Type 'number' is not assignable to type 'boolean'.
Expand All @@ -25,7 +25,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
!!! error TS2769: Types of property '1' are incompatible.
!!! error TS2769: Type at position 1 in source is not compatible with type at position 1 in target.
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/genericRestParameters2.types
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ f20(42, "hello", ...t3);
>t3 : boolean[]

f20(42, "hello", ...t2, true);
>f20(42, "hello", ...t2, true) : [number, string, string, ...boolean[]]
>f20(42, "hello", ...t2, true) : [number, string, string, ...boolean[], boolean]
>f20 : <T extends unknown[]>(...args: T) => T
>42 : 42
>"hello" : "hello"
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/iterableArrayPattern28.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,24): error
Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult<readonly [string, number]>'.
Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'.
Type '[string, boolean]' is not assignable to type 'readonly [string, number]'.
Types of property '1' are incompatible.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'boolean' is not assignable to type 'number'.
Overload 2 of 3, '(entries?: readonly (readonly [string, number])[]): Map<string, number>', gave the following error.
Type 'boolean' is not assignable to type 'number'.
Expand All @@ -26,7 +26,7 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern28.ts(2,24): error
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult<readonly [string, number]>'.
!!! error TS2769: Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'.
!!! error TS2769: Type '[string, boolean]' is not assignable to type 'readonly [string, number]'.
!!! error TS2769: Types of property '1' are incompatible.
!!! error TS2769: Type at position 1 in source is not compatible with type at position 1 in target.
!!! error TS2769: Type 'boolean' is not assignable to type 'number'.
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, number])[]): Map<string, number>', gave the following error.
!!! error TS2769: Type 'boolean' is not assignable to type 'number'.
24 changes: 12 additions & 12 deletions tests/baselines/reference/optionalTupleElements1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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'.
Property '2' is optional in type '[number, string, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
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'.
Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
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'.
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
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'.
Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
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'.
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
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'.
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, (string | undefined)?, (boolean | undefined)?]'.
Source provides no match for required element at position 0 in target.


==== tests/cases/conformance/types/tuple/optionalTupleElements1.ts (7 errors) ====
Expand All @@ -33,32 +33,32 @@ tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS232
t1 = t2; // Error
~~
!!! error TS2322: Type 'T2' is not assignable to type 'T1'.
!!! error TS2322: Property '2' is optional in type '[number, string, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
!!! 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: Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
!!! 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: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
!!! 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: Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
!!! 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: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
!!! 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: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, (string | undefined)?, (boolean | undefined)?]'.
!!! error TS2322: Source provides no match for required element at position 0 in target.
t4 = t1;
t4 = t2;
t4 = t3;
Expand Down
29 changes: 15 additions & 14 deletions tests/baselines/reference/restTupleElements1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
tests/cases/conformance/types/tuple/restTupleElements1.ts(3,22): error TS1257: A required element cannot follow an optional element.
tests/cases/conformance/types/tuple/restTupleElements1.ts(8,13): error TS1256: A rest element must be last in a tuple type.
tests/cases/conformance/types/tuple/restTupleElements1.ts(9,13): error TS2574: A rest element type must be an array type.
tests/cases/conformance/types/tuple/restTupleElements1.ts(10,13): error TS2574: A rest element type must be an array type.
tests/cases/conformance/types/tuple/restTupleElements1.ts(10,16): error TS8020: JSDoc types can only be used inside documentation comments.
tests/cases/conformance/types/tuple/restTupleElements1.ts(23,31): error TS2344: Type 'number[]' does not satisfy the constraint '[number, ...number[]]'.
Property '0' is optional in type 'number[]' but required in type '[number, ...number[]]'.
Source provides no match for required element at position 0 in target.
tests/cases/conformance/types/tuple/restTupleElements1.ts(24,31): error TS2344: Type '[]' does not satisfy the constraint '[number, ...number[]]'.
Source has 0 element(s) but target requires 1.
tests/cases/conformance/types/tuple/restTupleElements1.ts(29,18): error TS2344: Type 'number[]' does not satisfy the constraint '[number]'.
Expand All @@ -16,16 +15,18 @@ tests/cases/conformance/types/tuple/restTupleElements1.ts(32,31): error TS2344:
tests/cases/conformance/types/tuple/restTupleElements1.ts(33,31): error TS2344: Type '[string, ...number[]]' does not satisfy the constraint '[number, ...number[]]'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/restTupleElements1.ts(34,31): error TS2344: Type '[number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
Types of property '2' are incompatible.
Type 'string' is not assignable to type 'number'.
Type at positions 1 through 2 in source is not compatible with type at position 1 in target.
Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/restTupleElements1.ts(35,31): error TS2344: Type '[number, number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
Types of property '3' are incompatible.
Type 'string' is not assignable to type 'number'.
Type at positions 1 through 3 in source is not compatible with type at position 1 in target.
Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/types/tuple/restTupleElements1.ts(59,4): error TS2345: Argument of type '[]' is not assignable to parameter of type '[unknown, ...unknown[]]'.
Source has 0 element(s) but target requires 1.


==== tests/cases/conformance/types/tuple/restTupleElements1.ts (14 errors) ====
==== tests/cases/conformance/types/tuple/restTupleElements1.ts (13 errors) ====
type T00 = [string?];
type T01 = [string, string?];
type T02 = [string?, string]; // Error
Expand All @@ -36,8 +37,6 @@ tests/cases/conformance/types/tuple/restTupleElements1.ts(59,4): error TS2345: A
type T05 = [...[...[...string[]]]];
type T06 = [string, ...string[]];
type T07 = [...string[], string]; // Error
~~~~~~~~~~~
!!! error TS1256: A rest element must be last in a tuple type.
type T08 = [...string]; // Error
~~~~~~~~~
!!! error TS2574: A rest element type must be an array type.
Expand All @@ -61,7 +60,7 @@ tests/cases/conformance/types/tuple/restTupleElements1.ts(59,4): error TS2345: A
assign<[number, ...number[]], number[]>(); // Error
~~~~~~~~
!!! error TS2344: Type 'number[]' does not satisfy the constraint '[number, ...number[]]'.
!!! error TS2344: Property '0' is optional in type 'number[]' but required in type '[number, ...number[]]'.
!!! error TS2344: Source provides no match for required element at position 0 in target.
assign<[number, ...number[]], []>(); // Error
~~
!!! error TS2344: Type '[]' does not satisfy the constraint '[number, ...number[]]'.
Expand Down Expand Up @@ -90,13 +89,15 @@ tests/cases/conformance/types/tuple/restTupleElements1.ts(59,4): error TS2345: A
assign<[number, ...number[]], [number, number, string]>(); // Error
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2344: Type '[number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
!!! error TS2344: Types of property '2' are incompatible.
!!! error TS2344: Type 'string' is not assignable to type 'number'.
!!! error TS2344: Type at positions 1 through 2 in source is not compatible with type at position 1 in target.
!!! error TS2344: Type 'string | number' is not assignable to type 'number'.
!!! error TS2344: Type 'string' is not assignable to type 'number'.
assign<[number, ...number[]], [number, number, number, string]>(); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2344: Type '[number, number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
!!! error TS2344: Types of property '3' are incompatible.
!!! error TS2344: Type 'string' is not assignable to type 'number'.
!!! error TS2344: Type at positions 1 through 3 in source is not compatible with type at position 1 in target.
!!! error TS2344: Type 'string | number' is not assignable to type 'number'.
!!! error TS2344: Type 'string' is not assignable to type 'number'.

type T20 = [number, string, ...boolean[]];

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/restTupleElements1.types
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type T21 = T20[0];
>T21 : number

type T22 = T20[0 | 1];
>T22 : T22
>T22 : string | number

type T23 = T20[0 | 1 | 2];
>T23 : string | number | boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error
Types of parameters 'b' and 'args' are incompatible.
Type 'T' is not assignable to type '[b: T[0], ...x: T[number][]]'.
Type 'any[]' is not assignable to type '[b: T[0], ...x: T[number][]]'.
Property '0' is optional in type 'any[]' but required in type '[b: T[0], ...x: T[number][]]'.
Source provides no match for required element at position 0 in target.


==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ====
Expand Down Expand Up @@ -67,7 +67,7 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error
!!! error TS2345: Types of parameters 'b' and 'args' are incompatible.
!!! error TS2345: Type 'T' is not assignable to type '[b: T[0], ...x: T[number][]]'.
!!! error TS2345: Type 'any[]' is not assignable to type '[b: T[0], ...x: T[number][]]'.
!!! error TS2345: Property '0' is optional in type 'any[]' but required in type '[b: T[0], ...x: T[number][]]'.
!!! error TS2345: Source provides no match for required element at position 0 in target.
}

declare function f5<T extends any[], U>(f: (...args: T) => U): (...args: T) => U;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/spliceTuples.errors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests/cases/compiler/spliceTuples.ts(23,1): error TS2322: Type '[number, string, boolean, ...boolean[]]' is not assignable to type '[number, string, boolean, boolean, ...boolean[]]'.
Property '3' is optional in type '[number, string, boolean, ...boolean[]]' but required in type '[number, string, boolean, boolean, ...boolean[]]'.
Source provides no match for required element at position 3 in target.


==== tests/cases/compiler/spliceTuples.ts (1 errors) ====
Expand Down Expand Up @@ -28,5 +28,5 @@ tests/cases/compiler/spliceTuples.ts(23,1): error TS2322: Type '[number, string,
k6 = [1, ...sbb_];
~~
!!! error TS2322: Type '[number, string, boolean, ...boolean[]]' is not assignable to type '[number, string, boolean, boolean, ...boolean[]]'.
!!! error TS2322: Property '3' is optional in type '[number, string, boolean, ...boolean[]]' but required in type '[number, string, boolean, boolean, ...boolean[]]'.
!!! error TS2322: Source provides no match for required element at position 3 in target.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I keep reading this error and coming to it feeling kinda lacking in information. Maybe something like

Suggested change
!!! error TS2322: Source provides no match for required element at position 3 in target.
!!! error TS2322: Type '[number, string, boolean, ...boolean[]]' provides no match for required element at position 3 in type '[number, string, boolean, boolean, ...boolean[]]'.

I feel like yeah, we work with source/target all the time in the compiler, sure, but I think having the types right there, inline, make it easier to take in. It'd also be neat if we could, like, underline or highlight the tuple element we're referring to somehow, like


!!! error TS2322:   Type '[number, string, boolean, ...boolean[]]' provides no match for required element at position 3 in type '[number, string, boolean, boolean, ...boolean[]]'.
                                                    ~~~~~~~~~~~~                                                                                           ~~~~~~~

because referring to a tuple element index across two tuples, while concrete, feels like it can be hard to pick out what pair of elements are being compared when the tuples are long. Though that last part (the underlining) we can discuss/consider implementing another time. I do think restoring a slightly more detailed error message is warranted, however.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#41860 now keeps track of some ideas we have in mind here.


Loading