From 9019e399e5ae5063c31421dd6fdaabc4ce94834c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 7 May 2020 10:20:51 -0700 Subject: [PATCH] Add regression test --- .../intersectionsAndOptionalProperties.errors.txt | 5 +++++ .../reference/intersectionsAndOptionalProperties.js | 8 ++++++++ .../intersectionsAndOptionalProperties.symbols | 9 +++++++++ .../intersectionsAndOptionalProperties.types | 11 +++++++++++ .../compiler/intersectionsAndOptionalProperties.ts | 5 +++++ 5 files changed, 38 insertions(+) diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt b/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt index bcd0a6f841d..faa8b067b1a 100644 --- a/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt +++ b/tests/baselines/reference/intersectionsAndOptionalProperties.errors.txt @@ -46,4 +46,9 @@ tests/cases/compiler/intersectionsAndOptionalProperties.ts(20,5): error TS2322: ~~~~~~~ !!! error TS2322: Type 'null' is not assignable to type 'number | undefined'. } + + // Repro from #38348 + + const yy: number[] & [number, ...number[]] = [1]; + const xx: [number, ...number[]] = yy; \ No newline at end of file diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.js b/tests/baselines/reference/intersectionsAndOptionalProperties.js index b2f13a9f679..5bb0df9d27f 100644 --- a/tests/baselines/reference/intersectionsAndOptionalProperties.js +++ b/tests/baselines/reference/intersectionsAndOptionalProperties.js @@ -20,6 +20,11 @@ function foo(v: From) { x = v; // Error x.field = v.field; // Error } + +// Repro from #38348 + +const yy: number[] & [number, ...number[]] = [1]; +const xx: [number, ...number[]] = yy; //// [intersectionsAndOptionalProperties.js] @@ -31,3 +36,6 @@ function foo(v) { x = v; // Error x.field = v.field; // Error } +// Repro from #38348 +var yy = [1]; +var xx = yy; diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.symbols b/tests/baselines/reference/intersectionsAndOptionalProperties.symbols index c5504794e6e..e09f4dce5bb 100644 --- a/tests/baselines/reference/intersectionsAndOptionalProperties.symbols +++ b/tests/baselines/reference/intersectionsAndOptionalProperties.symbols @@ -62,3 +62,12 @@ function foo(v: From) { >field : Symbol(field, Decl(intersectionsAndOptionalProperties.ts, 14, 14)) } +// Repro from #38348 + +const yy: number[] & [number, ...number[]] = [1]; +>yy : Symbol(yy, Decl(intersectionsAndOptionalProperties.ts, 24, 5)) + +const xx: [number, ...number[]] = yy; +>xx : Symbol(xx, Decl(intersectionsAndOptionalProperties.ts, 25, 5)) +>yy : Symbol(yy, Decl(intersectionsAndOptionalProperties.ts, 24, 5)) + diff --git a/tests/baselines/reference/intersectionsAndOptionalProperties.types b/tests/baselines/reference/intersectionsAndOptionalProperties.types index 7f5af60c18e..98bc85c7e42 100644 --- a/tests/baselines/reference/intersectionsAndOptionalProperties.types +++ b/tests/baselines/reference/intersectionsAndOptionalProperties.types @@ -63,3 +63,14 @@ function foo(v: From) { >field : null } +// Repro from #38348 + +const yy: number[] & [number, ...number[]] = [1]; +>yy : number[] & [number, ...number[]] +>[1] : [number] +>1 : 1 + +const xx: [number, ...number[]] = yy; +>xx : [number, ...number[]] +>yy : number[] & [number, ...number[]] + diff --git a/tests/cases/compiler/intersectionsAndOptionalProperties.ts b/tests/cases/compiler/intersectionsAndOptionalProperties.ts index a5bc4a1580a..9878604c148 100644 --- a/tests/cases/compiler/intersectionsAndOptionalProperties.ts +++ b/tests/cases/compiler/intersectionsAndOptionalProperties.ts @@ -21,3 +21,8 @@ function foo(v: From) { x = v; // Error x.field = v.field; // Error } + +// Repro from #38348 + +const yy: number[] & [number, ...number[]] = [1]; +const xx: [number, ...number[]] = yy;