Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Jan 29, 2020
1 parent 262660d commit 3078223
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/baselines/reference/arrayFlatMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ const array: number[] = [];
const readonlyArray: ReadonlyArray<number> = [];
array.flatMap((): ReadonlyArray<number> => []); // ok
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok

// #19535

const [x] = [""].flatMap(undefined as () => string[] | string[][]);
x == "";


//// [arrayFlatMap.js]
var array = [];
var readonlyArray = [];
array.flatMap(function () { return []; }); // ok
readonlyArray.flatMap(function () { return []; }); // ok
// #19535
var x = [""].flatMap(undefined)[0];
x == "";
11 changes: 11 additions & 0 deletions tests/baselines/reference/arrayFlatMap.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
>flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.es2019.array.d.ts, --, --))
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es2019.array.d.ts, --, --))

// #19535

const [x] = [""].flatMap(undefined as () => string[] | string[][]);
>x : Symbol(x, Decl(arrayFlatMap.ts, 7, 7))
>[""].flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --))
>flatMap : Symbol(Array.flatMap, Decl(lib.es2019.array.d.ts, --, --))
>undefined : Symbol(undefined)

x == "";
>x : Symbol(x, Decl(arrayFlatMap.ts, 7, 7))

17 changes: 17 additions & 0 deletions tests/baselines/reference/arrayFlatMap.types
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,20 @@ readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
>(): ReadonlyArray<number> => [] : () => readonly number[]
>[] : undefined[]

// #19535

const [x] = [""].flatMap(undefined as () => string[] | string[][]);
>x : string | string[]
>[""].flatMap(undefined as () => string[] | string[][]) : (string | string[])[]
>[""].flatMap : <U, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>[""] : string[]
>"" : ""
>flatMap : <U, This = undefined>(callback: (this: This, value: string, index: number, array: string[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>undefined as () => string[] | string[][] : () => string[] | string[][]
>undefined : undefined

x == "";
>x == "" : boolean
>x : string | string[]
>"" : ""

5 changes: 5 additions & 0 deletions tests/cases/compiler/arrayFlatMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ const array: number[] = [];
const readonlyArray: ReadonlyArray<number> = [];
array.flatMap((): ReadonlyArray<number> => []); // ok
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok

// #19535

const [x] = [""].flatMap(undefined as () => string[] | string[][]);
x == "";

0 comments on commit 3078223

Please sign in to comment.