typescript - Typescript 在我的 Angular 项目中找不到 @types/spotify-api
问题描述
我安装@types/spotify-api
并对我的 tsconfig.json 进行了以下更改
"typeRoots": [
"node_modules/@types"
],
"types": [
"spotify-api"
],
例如,打字稿找不到PlaylistTrackResponse
。我不知道为什么,因为它与@types/node
其他项目中的类型的工作方式相同。我正在使用打字稿 3.7.5。
我完整的 tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"types": [
"spotify-api"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"disableTypeScriptVersionCheck": true
}
}
解决方案
不知道您是否还需要回答这个问题,因为您很久以前就问过这个问题,但您可以通过以下方式解决这个问题:
/// <reference types="spotify-api" />
在你班级的顶部,然后得到任何类型,如下所示:
SpotifyApi.PlaylistObjectSimplified
推荐阅读
- google-api - 如何从 Youtube Analytics API 获取观看率?
- security - OpenID Connect 如何处理服务链?
- haskell - 使用过滤器的初学者类型错误
- r - div类抓取
- sql - 如何处理动态查询
- javascript - jQuery 检查以测试 iframe 的内容未触发
- javascript - 为什么它适用于 nodejs 或任何其他 javascript 编译器?
- r - 如何测试数据框中的任何值是否超过限制
- google-api - Google API 调用:“此 URL 不支持 HTTP 方法 PUT。” URL 可能有什么问题?
- java - 基于两件事的重复数据删除数组