1

We just upgraded our application from Angular 4 to Angular 7. The site is up and running with ng serve locally and also working fine in multiple environments(ETE, QA, Pilot etc) with builds against each environment without the below fix. But when we run the unit tests we are getting the below error,

error TS2339: Property 'flatMap' does not exist on type 'any[] jasmine

Found a fix by adding "esnext.array" inside the tsconfig.json file under lib as pointed out in the question Typescript flatMap, flat, flatten doesn't exist on type any[].

Now my question is will it impact the site in anyway? My angular lib value is as below

"lib": [
      "es2018",
      "dom",
      "esnext.array"
    ]

Can somebody point me out the risk for adding esnext.array into the tsconfig.json file if any?

Geo j
  • 181
  • 3
  • 16

2 Answers2

0

The post you linked to recommended changing es2018 to es2019. Did you try that first? That seems like a safer option.

esnext.array is basically referencing draft specifications for the Javascript language. I'm not sure how stable they are but there is some chance that you will reference functionality that won't end up making it into the spec (and then won't be widely supported by browsers). Depending on your use case that may or may not be a big deal.

Kyle Anderson
  • 724
  • 3
  • 10
0

I had the same problem, and the solution was use esnext to your --lib instead of 'es2018', like below:

"compilerOptions": {
    "target": "es2015",
    "lib": ["dom", "esnext"]
}

I hope that it's helpfull :)