From 355706dadc8d2eb30f283e927d52d13736f6dd65 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 25 Aug 2020 13:20:38 -1000 Subject: [PATCH] Accept new baselines --- .../reference/variadicTuples1.errors.txt | 21 +++++++++++++++- tests/baselines/reference/variadicTuples1.js | 17 +++++++++++++ .../reference/variadicTuples1.symbols | 24 +++++++++++++++++++ .../baselines/reference/variadicTuples1.types | 23 ++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index db789540b9cda..416565221bbff 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -41,9 +41,12 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Typ 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(346,14): error TS7019: Rest parameter 'x' implicitly has an 'any[]' type. tests/cases/conformance/types/tuple/variadicTuples1.ts(354,26): error TS2322: Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/types/tuple/variadicTuples1.ts(393,19): error TS1256: A rest element must be last in a tuple type. +tests/cases/conformance/types/tuple/variadicTuples1.ts(396,20): error TS1256: A rest element must be last in a tuple type. +tests/cases/conformance/types/tuple/variadicTuples1.ts(397,12): error TS1256: A rest element must be last in a tuple type. -==== tests/cases/conformance/types/tuple/variadicTuples1.ts (20 errors) ==== +==== tests/cases/conformance/types/tuple/variadicTuples1.ts (23 errors) ==== // Variadics in tuple types type TV0 = [string, ...T]; @@ -496,4 +499,20 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(354,26): error TS2322: Ty callApi(getUser); callApi(getOrgUser); + + // Repro from #40235 + + type Numbers = number[]; + type Unbounded = [...Numbers, boolean]; + ~~~~~~~~~~ +!!! error TS1256: A rest element must be last in a tuple type. + const data: Unbounded = [false, false]; + + type U1 = [string, ...Numbers, boolean]; + ~~~~~~~~~~ +!!! error TS1256: A rest element must be last in a tuple type. + type U2 = [...[string, ...Numbers], boolean]; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1256: A rest element must be last in a tuple type. + type U3 = [...[string, number], boolean]; \ No newline at end of file diff --git a/tests/baselines/reference/variadicTuples1.js b/tests/baselines/reference/variadicTuples1.js index 8447634732776..ee7ebc5c6a769 100644 --- a/tests/baselines/reference/variadicTuples1.js +++ b/tests/baselines/reference/variadicTuples1.js @@ -387,6 +387,16 @@ function callApi(method: (...args: [...T, ob callApi(getUser); callApi(getOrgUser); + +// Repro from #40235 + +type Numbers = number[]; +type Unbounded = [...Numbers, boolean]; +const data: Unbounded = [false, false]; + +type U1 = [string, ...Numbers, boolean]; +type U2 = [...[string, ...Numbers], boolean]; +type U3 = [...[string, number], boolean]; //// [variadicTuples1.js] @@ -609,6 +619,7 @@ function callApi(method) { } callApi(getUser); callApi(getOrgUser); +var data = [false, false]; //// [variadicTuples1.d.ts] @@ -774,3 +785,9 @@ declare function getOrgUser(id: string, orgId: number, options?: { z?: boolean; }): void; declare function callApi(method: (...args: [...T, object]) => U): (...args_0: T) => U; +declare type Numbers = number[]; +declare type Unbounded = [...Numbers, boolean]; +declare const data: Unbounded; +declare type U1 = [string, ...Numbers, boolean]; +declare type U2 = [...[string, ...Numbers], boolean]; +declare type U3 = [...[string, number], boolean]; diff --git a/tests/baselines/reference/variadicTuples1.symbols b/tests/baselines/reference/variadicTuples1.symbols index 034eda43f5a9e..b8029f3fbc0dc 100644 --- a/tests/baselines/reference/variadicTuples1.symbols +++ b/tests/baselines/reference/variadicTuples1.symbols @@ -1327,3 +1327,27 @@ callApi(getOrgUser); >callApi : Symbol(callApi, Decl(variadicTuples1.ts, 380, 100)) >getOrgUser : Symbol(getOrgUser, Decl(variadicTuples1.ts, 378, 71)) +// Repro from #40235 + +type Numbers = number[]; +>Numbers : Symbol(Numbers, Decl(variadicTuples1.ts, 387, 20)) + +type Unbounded = [...Numbers, boolean]; +>Unbounded : Symbol(Unbounded, Decl(variadicTuples1.ts, 391, 24)) +>Numbers : Symbol(Numbers, Decl(variadicTuples1.ts, 387, 20)) + +const data: Unbounded = [false, false]; +>data : Symbol(data, Decl(variadicTuples1.ts, 393, 5)) +>Unbounded : Symbol(Unbounded, Decl(variadicTuples1.ts, 391, 24)) + +type U1 = [string, ...Numbers, boolean]; +>U1 : Symbol(U1, Decl(variadicTuples1.ts, 393, 39)) +>Numbers : Symbol(Numbers, Decl(variadicTuples1.ts, 387, 20)) + +type U2 = [...[string, ...Numbers], boolean]; +>U2 : Symbol(U2, Decl(variadicTuples1.ts, 395, 40)) +>Numbers : Symbol(Numbers, Decl(variadicTuples1.ts, 387, 20)) + +type U3 = [...[string, number], boolean]; +>U3 : Symbol(U3, Decl(variadicTuples1.ts, 396, 45)) + diff --git a/tests/baselines/reference/variadicTuples1.types b/tests/baselines/reference/variadicTuples1.types index f4aacc3a2a29f..094932f783583 100644 --- a/tests/baselines/reference/variadicTuples1.types +++ b/tests/baselines/reference/variadicTuples1.types @@ -1383,3 +1383,26 @@ callApi(getOrgUser); >callApi : (method: (...args_0: T, args_1: object) => U) => (...args_0: T) => U >getOrgUser : (id: string, orgId: number, options?: { y?: number | undefined; z?: boolean | undefined; } | undefined) => void +// Repro from #40235 + +type Numbers = number[]; +>Numbers : Numbers + +type Unbounded = [...Numbers, boolean]; +>Unbounded : (number | boolean)[] + +const data: Unbounded = [false, false]; +>data : (number | boolean)[] +>[false, false] : false[] +>false : false +>false : false + +type U1 = [string, ...Numbers, boolean]; +>U1 : [string, ...(number | boolean)[]] + +type U2 = [...[string, ...Numbers], boolean]; +>U2 : [string, ...(number | boolean)[]] + +type U3 = [...[string, number], boolean]; +>U3 : [string, number, boolean] +