Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add lib es2019 to Angular project recently updated to v10, in vs code?

My objective is a working Angular v10 project, using .flat() on arrays. Our team recently upgraded our Angular project to version 10. The project now, based on the Angular CLI, has the following files in the root:

  1. tsconfig.base.json
  2. tsconfig.json

Everything works, but our IDE (vs code), gives us the warning:

Property 'flat' does not exist on type 'string[][]'.ts(2339)

According to this answer on SO, adding es2019 to the lib property should fix the issue. But I have added "es2019" to both tsconfig.base.json and tsconfig.json to no help.

like image 318
DauleDK Avatar asked Jun 30 '20 18:06

DauleDK


People also ask

How do I import an existing Angular project into Visual Studio Code?

Now open Visual Studio Code. Go to "File" > "Open Folder" and select "First-Angular-Project" from the "Desktop". Now in the "TERMINAL" run ng new Angular-Project-Demo. Whenever it prompts with something like "Would you like to add Angular routing? (y/N)" press "y" and hit "ENTER".

How do I create a new component in Angular using Visual Studio Code?

Create a new Angular application using ng new or open an existing one. Open the command prompt or terminal. Alternatively, if you have your Angular application open in an IDE such as Visual Studio Code, you can use the built-in terminal. The new component will get created in a new folder, inside the src/app directory.

What is a package of TypeScript in Angular?

TypeScript is a primary language for Angular application development. It is a superset of JavaScript with design-time support for type safety and tooling. Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration.


1 Answers

In my case, I already had something in "lib" so I just changed the es from 2018 to 2019:

From:

"lib": ["es2018", "dom"]

To:

"lib": ["es2019", "dom"]

(And it took about 30-60 seconds before Code recognized the changes in my ts files)

like image 81
Brian Davis Avatar answered Oct 16 '22 18:10

Brian Davis