2016-06-29 14 views
6

Mam pewne problemy z typami. Kiedy uruchamiam npm start otrzymuję następujące błędy:Błędy kompilacji Angular2 - nie można znaleźć typów

> tsc && concurrently "npm run tscw" "npm run lite" 

node_modules/@angular/common/src/directives/ng_class.d.ts(72,35): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/common/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/common/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/common/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/common/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/forms/directives/select_control_value_accessor.d.ts(18,17): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/common/src/pipes/async_pipe.d.ts(29,29): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/pipes/async_pipe.d.ts(35,38): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/pipes/async_pipe.d.ts(37,39): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/common/src/pipes/async_pipe.d.ts(39,44): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/application_ref.d.ts(39,88): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/application_ref.d.ts(99,42): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/application_ref.d.ts(174,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(24,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts(26,16): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,123): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/di/reflective_provider.d.ts(105,165): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'. 
node_modules/@angular/core/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'. 
node_modules/@angular/core/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/collection.d.ts(100,41): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/collection.d.ts(101,22): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/collection.d.ts(102,25): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/component_resolver.d.ts(8,53): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/component_resolver.d.ts(12,44): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(62,148): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(103,144): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(108,139): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/linker/dynamic_component_loader.d.ts(109,135): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(28,22): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(30,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(32,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(34,15): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/core/src/reflection/reflector.d.ts(36,16): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/core/src/testability/testability.d.ts(40,20): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/http/src/headers.d.ts(29,18): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/http/src/headers.d.ts(45,59): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/http/src/url_search_params.d.ts(11,16): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/platform-browser-dynamic/platform_browser_dynamic.d.ts(75,90): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(27,54): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(33,51): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(38,56): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(47,65): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/directives/router_outlet.d.ts(58,60): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/async.d.ts(27,33): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/async.d.ts(28,45): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(4,17): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(5,17): error TS2304: Cannot find name 'Set'. 
node_modules/@angular/router-deprecated/src/facade/lang.d.ts(70,59): error TS2304: Cannot find name 'Map'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(2,14): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(11,50): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/instruction.d.ts(125,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/instruction.d.ts(161,25): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/instruction.d.ts(179,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/instruction.d.ts(182,25): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/interfaces.d.ts(21,107): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/interfaces.d.ts(39,104): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/interfaces.d.ts(57,109): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/interfaces.d.ts(80,109): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/interfaces.d.ts(102,114): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/lifecycle/lifecycle_annotations.d.ts(29,100): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/route_config/route_config_impl.d.ts(105,19): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/route_definition.d.ts(20,20): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/route_definition.d.ts(35,20): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/route_registry.d.ts(52,66): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(56,50): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(68,46): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(86,45): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(99,34): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(107,64): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(112,85): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(114,51): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(116,72): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(122,48): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(128,70): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(140,43): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(144,29): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(150,19): error TS2304: Cannot find name 'Promise'. 
node_modules/@angular/router-deprecated/src/router.d.ts(162,70): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(10,66): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(66,60): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/Observable.d.ts(66,70): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/operator/toPromise.d.ts(7,59): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/operator/toPromise.d.ts(7,69): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/operator/toPromise.d.ts(9,9): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/operator/toPromise.d.ts(10,26): error TS2304: Cannot find name 'Promise'. 
node_modules/rxjs/operator/toPromise.d.ts(10,36): error TS2304: Cannot find name 'Promise'. 
src/classes/animal.ts(42,18): error TS2339: Property 'startsWith' does not exist on type 'string'. 

Inni mieli ten problem w ciągu ostatnich miesięcy, ale żadna z tych poprawek nie pracował dla mnie.

Wszelkie pomysły? (Kątowa 2)

+0

http://stackoverflow.com/a/38876022/361714 – Tom

Odpowiedz

10

Jeśli używasz --target = ES5, trzeba będzie dodać linię gdzieś w aplikacji (na przykład na szczycie .TS plik gdzie zadzwonić bootstrap):

<reference path="node_modules/angular2/typings/browser.d.ts"/> 

zobaczyć ten wpis: Angular 2 typescript can't find names

osobiście włączony do ES6 który działa perfekcyjnie tak daleko. Polecam również zrobić QuickStart 5 minut i serię poradnik dla Angular2 ponieważ można go używać jako stabilny szkielet dla kolejnych projektów: https://angular.io/guide/quickstart

Powodzenia

+1

Cudownie, es6 załatwił sprawę. Dzięki! – Taimur

0

Pobiegłem do podobnego problemu, ale w Visual studio niedawna i zrobiłem dużo wyszukiwania w Google, ale nie mogłem znaleźć żadnego postu mówiącego o problemie występującym szczególnie podczas uruchamiania aplikacji internetowej w Visual Studio. Wyglądało na to, że moja aplikacja mogłaby być nawet zbudowana pomyślnie przez npm, chociaż nie mogła w VS. W końcu znalazłem powód po kilku nocnych pracach nad nim. Chciałbym podzielić się moim doświadczeniem tutaj, ponieważ wygląda na to, że w tym studiu wizualnym niewiele jest mowy o tym problemie. Mam nadzieję, że pomoże to innym osobom, które nie są do końca podobnym maszynopisem w VS, ponieważ łatwo znalazłem ten wpis, gdy szukałem go w Google dla tego problemu.

Zasadniczo w VS znajduje się narzędzie do pisania, które można zobaczyć i jego wersję w menu Narzędzia-> Rozszerzenia i aktualizacje. Mój projekt jest dokładnie tym, który jest tworzony przez samouczek VISUAL STUDIO 2015 QUICKSTART tutaj: https://angular.io/guide/visual-studio-2015.

W rzeczywistości mój VS miał rozszerzenie maszyn 1.8.1, które różni się od 2.2 wymagane w samouczku. Myślę, że 1.8.xx jest domyślną wersją maszynopisu pochodzącą ze społeczności VS 2015. To, co zrobiłem, aby rozwiązać ten problem, to po prostu usunięcie starej wersji i ponowne zainstalowanie maszynopisu 2.2 w VS. Trudną rzeczą, którą warto wspomnieć, jest to, jak ją odinstalować, ponieważ przycisk Odinstaluj został wyłączony w moim VS. W szczególności przejdź do folderu C: \ ProgramData \ Package Cache \ i wyszukaj w nim TypeScript_Dev14.msi. Następnie kliknij prawym przyciskiem jeden z numeru wersji w VS, aby go odinstalować. Po tym nie powinieneś już widzieć maszynopisu w rozszerzeniach VS. Następnie przejdź Rozszerzenia i aktualizacje w VS, aby wyszukać maszynopis 2.2 i zainstalować go. Następnie moja kompilacja w VS przebiega normalnie. Wpadłem na pomysł tutaj w komentarzu Simona Weave'a. Dziękuję ci za uratowanie mi życia. http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/

Czego wciąż nie rozumiem w samouczku, to napisanie, że instalowanie maszynopisu może być wykonane za pomocą instalacji nmp -g, którą faktycznie zrobiłem lub poprzez pobranie i zainstalowanie TypeScript 2.2 dla Visual Studio 2015. Ale wydaje się, że to pierwsze nie działa, ponieważ nie zmienia narzędzia maszynopis w VS.

Powiązane problemy