Question: I'm using Chrome 70 and Chrome does add methods `.flatMap`, `.flatten`, `.flat`. So my code does run as expected. Unfortunately, TypeScript doesn't like it.

```
// data.flatMap lint error
export const transformData = (data: any[]) => data.flatMap(abc => [
   parentObj(abc),
   ...generateTasks(abc)
]);

```

The warning I got is `TS2339: Property 'flatMap' does not exist on type 'any[]'.`

I'm using Angular 6, which uses Typescript ~2.9.2, and I already include `import 'core-js/es7/array';` in `polyfills.ts`.

My guess is that there is no typing for these methods, and I did try to `npm run -dev @types/array.prototype.flatmap` but still not solve.

Answer: 
If you're are in a lower version than es2019, you can implement a shim to provide similar functionality to `.flat()` and `.flatMap()` provided by later libraries.

To flat single level array

```
arr.reduce((acc, val) => acc.concat(val), []);

```

To flat multi level array

```
function flatDeep(arr, d = 1) {
   return d > 0 ? arr.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatDeep(val, d - 1) : val), []) : arr.slice();
};

```

to know deeply you can also check below link

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat>
I tried most answers and they didn't work for me.
IDE: VScode

but this did

```sh
npm i -D @types/node

```