Error TS2304: Cannot find the name "X" in the file app.components.ts and main.ts of the angular 4 project

new for typescript. Using neovim, ubuntu 16.04 and various vim typescript plugins tsuquyomi , leafgarland/typescript-vim , mhartington/nvim-typescript , and I'm sure I configured them correctly.

I have successfully installed @ angular / cli and I am trying to complete the tutorial, but I have an error that I do not understand.

 `1 .._modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts|| TS2304: Cannot find name 'Iterable'. 2 ../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts|| TS2304: Cannot find name 'Map'. 3 ../node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts|| TS2304: Cannot find name 'Map'. 4 ../node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts|| TS2304: Cannot find name 'Iterable'. 5 damn/node_modules/@angular/core/src/change_detection/differs/keyvalue_differs.d.ts|| TS2304: Cannot find name 'Map'. 6 ..//node_modules/@angular/core/src/di/reflective_provider.d.ts|| TS2304: Cannot find name 'Map'. 7 ../node_modules/@angular/core/src/di/reflective_provider.d.ts|| TS2304: Cannot find name 'Map'. 8 ../node_modules/rxjs/Observable.d.ts|| TS2693: 'Promise' only refers to a type, but is being used as a value here.` 

I tried everything that I think from

tries to use the following tsconfig properties. Glob Property:

 "filesGlob": [ "main.ts", "typings.d.ts", "app/**/*.ts", "!app/**/*.spec.ts" ], 

for intalling angular / core-js and @ types / core-js and typings

 npm install --save-dev @types/core-js npm install @types/node --save 

Edited tsconfig.json file

 { "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, "moduleResolution": "node", "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "types": ["node"], "typeRoots": [ "node_modules/@types" ], "files": [ "main.ts", "typings.d.ts" ], "filesGlob": [ "main.ts", "typings.d.ts", "app/**/*.ts" ], "lib": [ "es2016", "dom" ] } } 

I also edited the tsconfig.app.json file

 { "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", "types": [], "typeRoots": [ "../node_modules/@types/" ] }, "exclude": [ "test.ts", "**/*.spec.ts" ] } 

However, errors still exist in my app.components.ts file, and main.ts are all these changes.

+5
source share
2 answers

I included the following line at the beginning of the above files, and the problem seems to be resolved.

 ///<reference path="../../node_modules/typescript/lib/lib.es6.d.ts"/> 

The competition that arises for me is due to the fact that it installs lib on es6, and I do not understand what actually causes my problem. Any hints would be appreciated.

0
source

Add "skipLibCheck": true to "compilerOptions" in tsconfig.json

0
source

Source: https://habr.com/ru/post/1270033/


All Articles