forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayFlatMap.types
More file actions
42 lines (35 loc) · 2.07 KB
/
arrayFlatMap.types
File metadata and controls
42 lines (35 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
=== tests/cases/compiler/arrayFlatMap.ts ===
const array: number[] = [];
>array : number[]
>[] : undefined[]
const readonlyArray: ReadonlyArray<number> = [];
>readonlyArray : readonly number[]
>[] : undefined[]
array.flatMap((): ReadonlyArray<number> => []); // ok
>array.flatMap((): ReadonlyArray<number> => []) : number[]
>array.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>array : number[]
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>(): ReadonlyArray<number> => [] : () => readonly number[]
>[] : undefined[]
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
>readonlyArray.flatMap((): ReadonlyArray<number> => []) : number[]
>readonlyArray.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>readonlyArray : readonly number[]
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U, thisArg?: This) => (U extends readonly (infer V)[] ? V : U)[]
>(): 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[]
>"" : ""