【发布时间】:2016-06-20 02:53:13
【问题描述】:
试图让 Angular v3 路由器示例工作。 http://plnkr.co/edit/ER0tf8fpGHZiuVWB7Q07?p=preview
http://plnkr.co/edit/ER0tf8fpGHZiuVWB7Q07?p=preview
我的 package.json 在下面,但是当我运行 npm run tsc 时,我得到了错误...
app/crisis-center/crisis-center.routes.ts(14,5): error TS2322: Type '{ path: string;组件:危机中心组件的类型;索引:布尔值; children: ({ path: string...' 不能分配给类型 'Route[]'。
键入'{路径:字符串;组件:危机中心组件的类型;索引:布尔值;孩子:({路径:字符串...'不可分配给类型'Route'。 对象字面量只能指定已知属性,而 'index' 不存在于类型 'Route' 中。
app/crisis-center/crisis-detail.component.ts(46,17):错误 TS7006:参数 'crisis' 隐含地具有 'any' 类型。
app/crisis-center/crisis-detail.component.ts(81,12): error TS2322: Type 'Observable' is notassignable to type 'Observable |布尔值'。 类型 'Observable' 不可分配给类型 'boolean'。
app/crisis-center/crisis-list.component.ts(35,17):错误 TS7006:参数“crises”隐含地具有“任何”类型。
app/crisis-center/crisis.service.ts(12,21):错误 TS2304:找不到名称“Promise”。”
包.json
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0-rc.2",
"@angular/compiler": "2.0.0-rc.2",
"@angular/core": "2.0.0-rc.2",
"@angular/http": "2.0.0-rc.2",
"@angular/platform-browser": "2.0.0-rc.2",
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
"@angular/router": "^3.0.0-alpha.7",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.2",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.12",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.9.0-dev.20160409",
"typings":"^1.0.4"
}
}
【问题讨论】: