mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 21:07:52 -05:00
4
src/lib/esnext.array.d.ts
vendored
4
src/lib/esnext.array.d.ts
vendored
@@ -11,7 +11,7 @@ interface ReadonlyArray<T> {
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined> (
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U|U[],
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
|
||||
thisArg?: This
|
||||
): U[]
|
||||
|
||||
@@ -125,7 +125,7 @@ interface Array<T> {
|
||||
* thisArg is omitted, undefined is used as the this value.
|
||||
*/
|
||||
flatMap<U, This = undefined> (
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U|U[],
|
||||
callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray<U>,
|
||||
thisArg?: This
|
||||
): U[]
|
||||
|
||||
|
||||
12
tests/baselines/reference/arrayFlatMap.js
Normal file
12
tests/baselines/reference/arrayFlatMap.js
Normal file
@@ -0,0 +1,12 @@
|
||||
//// [arrayFlatMap.ts]
|
||||
const array: number[] = [];
|
||||
const readonlyArray: ReadonlyArray<number> = [];
|
||||
array.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
|
||||
|
||||
//// [arrayFlatMap.js]
|
||||
var array = [];
|
||||
var readonlyArray = [];
|
||||
array.flatMap(function () { return []; }); // ok
|
||||
readonlyArray.flatMap(function () { return []; }); // ok
|
||||
20
tests/baselines/reference/arrayFlatMap.symbols
Normal file
20
tests/baselines/reference/arrayFlatMap.symbols
Normal file
@@ -0,0 +1,20 @@
|
||||
=== tests/cases/compiler/arrayFlatMap.ts ===
|
||||
const array: number[] = [];
|
||||
>array : Symbol(array, Decl(arrayFlatMap.ts, 0, 5))
|
||||
|
||||
const readonlyArray: ReadonlyArray<number> = [];
|
||||
>readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5))
|
||||
>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.esnext.array.d.ts, --, --))
|
||||
|
||||
array.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
>array.flatMap : Symbol(Array.flatMap, Decl(lib.esnext.array.d.ts, --, --))
|
||||
>array : Symbol(array, Decl(arrayFlatMap.ts, 0, 5))
|
||||
>flatMap : Symbol(Array.flatMap, Decl(lib.esnext.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.esnext.array.d.ts, --, --))
|
||||
|
||||
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
>readonlyArray.flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.array.d.ts, --, --))
|
||||
>readonlyArray : Symbol(readonlyArray, Decl(arrayFlatMap.ts, 1, 5))
|
||||
>flatMap : Symbol(ReadonlyArray.flatMap, Decl(lib.esnext.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.esnext.array.d.ts, --, --))
|
||||
|
||||
25
tests/baselines/reference/arrayFlatMap.types
Normal file
25
tests/baselines/reference/arrayFlatMap.types
Normal file
@@ -0,0 +1,25 @@
|
||||
=== tests/cases/compiler/arrayFlatMap.ts ===
|
||||
const array: number[] = [];
|
||||
>array : number[]
|
||||
>[] : undefined[]
|
||||
|
||||
const readonlyArray: ReadonlyArray<number> = [];
|
||||
>readonlyArray : ReadonlyArray<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 | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>array : number[]
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<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 | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>readonlyArray : ReadonlyArray<number>
|
||||
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
|
||||
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<number>
|
||||
>[] : undefined[]
|
||||
|
||||
6
tests/cases/compiler/arrayFlatMap.ts
Normal file
6
tests/cases/compiler/arrayFlatMap.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// @lib: esnext
|
||||
|
||||
const array: number[] = [];
|
||||
const readonlyArray: ReadonlyArray<number> = [];
|
||||
array.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
|
||||
Reference in New Issue
Block a user