错误 TS2339:属性 'results' 在类型 'Response' 上不存在
error TS2339: Property 'results' does not exist on type 'Response'
我遵循一段代码构建和应用程序,使用 angular2、typescript 和 firebase 从 last.fm 收集数据。
源代码可以在这里找到:https://github.com/vtts/mytunes
问题如何转换 json 调用的结果?
github
上的源代码
https://github.com/vtts/mytunes/blob/master/app/music/services/music.srv.ts
我收到以下错误:
app/music/services/music.service.ts(29,39): error TS2339: Property 'results' does not exist on type 'Response'.
app/music/services/music.service.ts(51,36): error TS2339: Property 'album' does not exist on type 'Response'.
package.json
{
"name": "mytunes",
"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": {
"angular2": "2.0.0-beta.15",
"bootstrap": "^3.3.6",
"es6-shim": "^0.35.0",
"firebase": "^2.4.2",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",
"zone.js": "0.6.10"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^0.7.12"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "js"
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
Last.fm 休息 API
我正在使用以下 REST APIs:
而不是重新使用类型为 Response
的变量 res
res = res.json();
新建一个
let result = res.json();
然后使用 result
代替 res
我遵循一段代码构建和应用程序,使用 angular2、typescript 和 firebase 从 last.fm 收集数据。
源代码可以在这里找到:https://github.com/vtts/mytunes
问题如何转换 json 调用的结果?
github
上的源代码https://github.com/vtts/mytunes/blob/master/app/music/services/music.srv.ts
我收到以下错误:
app/music/services/music.service.ts(29,39): error TS2339: Property 'results' does not exist on type 'Response'.
app/music/services/music.service.ts(51,36): error TS2339: Property 'album' does not exist on type 'Response'.
package.json
{
"name": "mytunes",
"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": {
"angular2": "2.0.0-beta.15",
"bootstrap": "^3.3.6",
"es6-shim": "^0.35.0",
"firebase": "^2.4.2",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"systemjs": "0.19.26",
"zone.js": "0.6.10"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^0.7.12"
}
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "js"
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
Last.fm 休息 API
我正在使用以下 REST APIs:
而不是重新使用类型为 Response
res
res = res.json();
新建一个
let result = res.json();
然后使用 result
代替 res