2017-04-03 49 views
1

我已經更新了我的angular2到當前版本,但我得到了以下錯誤:看起來有一個問題在茉莉花索引文件。Angular2到Angular4更新錯誤

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:40:37 A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:40:45 Cannot find name 'keyof'.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:40:51 '=' expected.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:42:45 A parameter initializer is only allowed in a function or constructor implementation.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:42:55 Cannot find name 'keyof'.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:42:61 '=' expected.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:58:41 Cannot find name 'Partial'.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:99:21 Cannot find name 'Partial'.

ERROR in [default] C:\src\Angular2\BuyPracticeTest_AV4\node_modules\@types\jasmine\index.d.ts:99:34 Cannot find name 'Partial'.

這是我的package.json文件:

{ 
    "name": "buy-practice-test", 
    "version": "0.0.0", 
    "license": "MIT", 
    "angular-cli": {}, 
    "scripts": { 
    "start": "ng serve", 
    "lint": "tslint \"src/**/*.ts\"", 
    "test": "ng test", 
    "pree2e": "webdriver-manager update", 
    "e2e": "protractor" 
    }, 
    "private": true, 
    "dependencies": { 
    "@angular/common": "^2.4.10", 
    "@angular/compiler": "^2.4.10", 
    "@angular/core": "^2.4.10", 
    "@angular/forms": "^2.4.10", 
    "@angular/http": "^2.4.10", 
    "@angular/platform-browser": "^2.4.10", 
    "@angular/platform-browser-dynamic": "^2.4.10", 
    "@angular/router": "^3.4.10", 
    "angular2-datatable": "^0.5.3", 
    "core-js": "^2.4.1", 
    "ng2-pagination": "^0.5.1", 
    "ng2-table": "^1.3.2", 
    "rxjs": "5.0.0-beta.12", 
    "ts-helpers": "^1.1.1", 
    "zone.js": "^0.6.23" 
    }, 
    "devDependencies": { 
    "@types/jasmine": "^2.5.47", 
    "@types/node": "^6.0.68", 
    "angular-cli": "1.0.0-beta.18", 
    "codelyzer": "1.0.0-beta.1", 
    "jasmine-core": "2.4.1", 
    "jasmine-spec-reporter": "2.5.0", 
    "karma": "1.2.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-cli": "^1.0.1", 
    "karma-jasmine": "^1.0.2", 
    "karma-remap-istanbul": "^0.2.1", 
    "protractor": "4.0.9", 
    "ts-node": "1.2.1", 
    "tslint": "3.13.0", 
    "typescript": "~2.0.3" 
    } 
} 

回答

1

keyof在打字稿2.1引入,並在您的package.json我看到打字稿2.0.3。

不幸的是,@ angular-cli/ast-tools @ 1.0.16依賴於typescript 2.0.10,所以你可能無法升級到最新的typescript版本(2.2.2)。不過,您可能會降級茉莉花或@類型/茉莉花。

我建議您以較小的步驟進行升級。即使用npm outdated來查看您可以根據您的所有依賴項升級到的版本。一次升級一些庫 - 定期檢查以確保你沒有損壞任何東西。在您升級了可以升級之後,將@angular升級到4.0。

+0

讓我試試。謝謝 – wal

+0

我已經更新了Typescript到2.2.2,但我得到了另一個錯誤。模塊構建失敗:TypeError:無法讀取屬性'排除'未定義 在applyDefaults \ awesome-typescript-loader \ src \ instance.ts:266:72) 在Object.ensureInstance – wal

+0

對不起,我更新了我的文章。我建議你逐步更新。我認爲基於angular-cli,你只能升級到[email protected]。再次從頭開始,並使用'npm過時' – pixelbits