最近ネイティブスクリプトの勉強をしているのですが、プロジェクトを始めるたびになんかしらのエラーが発生します
ちょっと長いですが、こちらがエラー内容です
@angular/compiler/src/directive_normalizer.d.ts(39,72): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/directive_normalizer.d.ts(41,74): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/i18n/extractor.d.ts(14,33): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/i18n/extractor.d.ts(22,35): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/jit/compiler.d.ts(41,49): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/jit/compiler.d.ts(43,65): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/metadata_resolver.d.ts(67,104): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/resource_loader.d.ts(13,23): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/util.d.ts(32,18): error TS2304: Cannot find name 'Promise'. @angular/compiler/src/util.d.ts(33,46): error TS2304: Cannot find name 'Promise'. @angular/core/src/application_init.d.ts(17,27): error TS2304: Cannot find name 'Promise'. @angular/core/src/application_ref.d.ts(116,76): error TS2304: Cannot find name 'Promise'. @angular/core/src/application_ref.d.ts(132,110): error TS2304: Cannot find name 'Promise'. @angular/core/src/application_ref.d.ts(162,67): error TS2304: Cannot find name 'Promise'. @angular/core/src/application_ref.d.ts(164,101): error TS2304: Cannot find name 'Promise'. @angular/core/src/linker/compiler.d.ts(43,49): error TS2304: Cannot find name 'Promise'. @angular/core/src/linker/compiler.d.ts(51,65): error TS2304: Cannot find name 'Promise'. @angular/core/src/linker/ng_module_factory_loader.d.ts(14,34): error TS2304: Cannot find name 'Promise'. @angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(28,25): error TS2304: Cannot find name 'Promise'. @angular/core/src/util/lang.d.ts(12,53): error TS2304: Cannot find name 'Promise'. @angular/router/src/config.d.ts(310,85): error TS2304: Cannot find name 'Promise'. @angular/router/src/interfaces.d.ts(78,99): error TS2304: Cannot find name 'Promise'. @angular/router/src/interfaces.d.ts(157,109): error TS2304: Cannot find name 'Promise'. @angular/router/src/interfaces.d.ts(229,162): error TS2304: Cannot find name 'Promise'. @angular/router/src/interfaces.d.ts(299,89): error TS2304: Cannot find name 'Promise'. @angular/router/src/interfaces.d.ts(367,50): error TS2304: Cannot find name 'Promise'. @angular/router/src/router.d.ts(285,70): error TS2304: Cannot find name 'Promise'. @angular/router/src/router.d.ts(307,59): error TS2304: Cannot find name 'Promise'. @angular/router/src/router_module.d.ts(186,23): error TS2304: Cannot find name 'Promise'. @angular/router/src/utils/collection.d.ts(28,79): error TS2304: Cannot find name 'Promise'. @types/core-js/index.d.ts(39,27): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(226,38): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(231,35): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(236,37): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(327,13): error TS2300: Duplicate identifier 'log'. @types/core-js/index.d.ts(349,33): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(350,31): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(351,34): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(352,34): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(353,34): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(354,34): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(355,61): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(356,60): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(357,65): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(357,97): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(358,60): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(359,58): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(360,59): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(361,58): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(362,61): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(362,117): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(363,42): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(365,81): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(366,78): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(367,76): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(368,73): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(431,6): error TS2304: Cannot find name 'Symbol'. @types/core-js/index.d.ts(431,26): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(456,39): error TS2304: Cannot find name 'Promise'. @types/core-js/index.d.ts(464,59): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(465,59): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(466,42): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(467,48): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(468,69): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(472,40): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(474,48): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(494,55): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(495,45): error TS2304: Cannot find name 'PropertyKey'. @types/core-js/index.d.ts(535,42): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(536,39): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(537,41): error TS2304: Cannot find name 'IterableIterator'. @types/core-js/index.d.ts(623,16): error TS2304: Cannot find name 'MapConstructor'. @types/core-js/index.d.ts(624,16): error TS2304: Cannot find name 'SetConstructor'. @types/core-js/index.d.ts(625,20): error TS2304: Cannot find name 'WeakMapConstructor'. @types/core-js/index.d.ts(626,20): error TS2304: Cannot find name 'WeakSetConstructor'. @types/core-js/index.d.ts(627,20): error TS2304: Cannot find name 'PromiseConstructor'. @types/core-js/index.d.ts(646,53): error TS2304: Cannot find name 'Iterator'. @types/core-js/index.d.ts(657,35): error TS2304: Cannot find name 'Promise'. @types/core-js/index.d.ts(1280,36): error TS2339: Property 'for' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1284,43): error TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1288,50): error TS2339: Property 'isConcatSpreadable' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1292,40): error TS2339: Property 'iterator' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1296,38): error TS2339: Property 'keyFor' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1300,37): error TS2339: Property 'match' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1304,39): error TS2339: Property 'replace' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1308,38): error TS2339: Property 'search' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1312,39): error TS2339: Property 'species' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1316,37): error TS2339: Property 'split' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1320,43): error TS2339: Property 'toPrimitive' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1324,43): error TS2339: Property 'toStringTag' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(1328,43): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2059,36): error TS2339: Property 'for' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2063,43): error TS2339: Property 'hasInstance' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2067,50): error TS2339: Property 'isConcatSpreadable' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2071,40): error TS2339: Property 'iterator' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2075,38): error TS2339: Property 'keyFor' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2079,37): error TS2339: Property 'match' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2083,39): error TS2339: Property 'replace' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2087,38): error TS2339: Property 'search' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2091,39): error TS2339: Property 'species' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2095,37): error TS2339: Property 'split' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2099,43): error TS2339: Property 'toPrimitive' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2103,43): error TS2339: Property 'toStringTag' does not exist on type 'SymbolConstructor'. @types/core-js/index.d.ts(2107,43): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'. nativescript-angular/platform-common.d.ts(32,67): error TS2304: Cannot find name 'Promise'. nativescript-angular/platform-common.d.ts(33,101): error TS2304: Cannot find name 'Promise'. nativescript-angular/platform-providers.d.ts(1,23): error TS2307: Cannot find module 'ui/frame'. nativescript-angular/platform-providers.d.ts(2,22): error TS2307: Cannot find module 'ui/page'. nativescript-angular/platform-providers.d.ts(4,24): error TS2307: Cannot find module 'platform'. nativescript-angular/resource-loader.d.ts(4,23): error TS2304: Cannot find name 'Promise'. nativescript-angular/router.d.ts(3,23): error TS2307: Cannot find module 'ui/frame'. nativescript-angular/router/ns-location-strategy.d.ts(2,45): error TS2307: Cannot find module 'ui/frame'. nativescript-angular/router/ns-module-factory-loader.d.ts(7,25): error TS2304: Cannot find name 'Promise'. nativescript-angular/router/page-router-outlet.d.ts(3,24): error TS2307: Cannot find module 'platform'. nativescript-angular/router/page-router-outlet.d.ts(4,23): error TS2307: Cannot find module 'ui/frame'. nativescript-angular/router/router-extensions.d.ts(3,23): error TS2307: Cannot find module 'ui/frame'. nativescript-angular/router/router-extensions.d.ts(10,67): error TS2304: Cannot find name 'Promise'. nativescript-angular/router/router-extensions.d.ts(11,72): error TS2304: Cannot find name 'Promise'. rxjs/Observable.d.ts(69,60): error TS2304: Cannot find name 'Promise'. rxjs/Observable.d.ts(69,70): error TS2304: Cannot find name 'Promise'. tns-core-modules/tns-core-modules.d.ts(14,18): error TS2304: Cannot find name 'Promise'. tns-core-modules/tns-core-modules.d.ts(17,27): error TS2304: Cannot find name 'Headers'. tns-core-modules/tns-core-modules.d.ts(19,44): error TS2304: Cannot find name 'RequestInit'. tns-core-modules/tns-core-modules.d.ts(19,58): error TS2304: Cannot find name 'Promise'. tns-core-modules/tns-core-modules.d.ts(110,18): error TS2300: Duplicate identifier 'log'. TypeScript compiler failed with exit code 1
ネットで調べたところ、package.jsonもしくはtsconfig系のエラーであることが多いそうなので、
とりあえず前回は動いていたコードを持って来ることで解決しました
// tsconfig.json { "compilerOptions": { "module": "commonjs", "target": "es5", "experimentalDecorators": true, "emitDecoratorMetadata": true, "noEmitHelpers": true, "noEmitOnError": true, "lib": [ "es6", "dom", "es2015.iterable" ], "baseUrl": ".", "paths": { "*": [ "./node_modules/tns-core-modules/*", "./node_modules/*" ] } }, "exclude": [ "node_modules", "platforms", "**/*.aot.ts" ] } // package.json { "description": "NativeScript Application", "license": "SEE LICENSE IN <your-license-filename>", "readme": "NativeScript Application", "repository": "<fill-your-repository-here>", "nativescript": { "id": "org.nativescript.tnschat", "tns-android": { "version": "3.0.1" } }, "dependencies": { "@angular/animations": "~4.0.0", "@angular/common": "~4.0.0", "@angular/compiler": "~4.0.0", "@angular/core": "~4.0.0", "@angular/forms": "~4.0.0", "@angular/http": "~4.0.0", "@angular/platform-browser": "~4.0.0", "@angular/platform-browser-dynamic": "~4.0.0", "@angular/router": "~4.0.0", "email-validator": "^1.0.7", "nativescript-angular": "~3.0.0", "nativescript-social-share": "^1.3.2", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~5.2.0", "tns-core-modules": "~3.0.0", "zone.js": "0.8.2" }, "devDependencies": { "babel-traverse": "6.24.1", "babel-types": "6.24.1", "babylon": "6.17.2", "lazy": "1.0.11", "nativescript-dev-android-snapshot": "^0.*.*", "nativescript-dev-typescript": "^0.4.0", "typescript": "~2.2.1" } }
コメントを残す