Typescript 打字脚本可以';在我的angular项目中找不到@types/spotify api
我安装了Typescript 打字脚本可以';在我的angular项目中找不到@types/spotify api,typescript,Typescript,我安装了@types/spotify api,并对我的tsconfig.json进行了以下更改 "typeRoots": [ "node_modules/@types" ], "types": [ "spotify-api" ], { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", "outDir": "./dist/out-tsc", "sourceMap": true,
@types/spotify api
,并对我的tsconfig.json进行了以下更改
"typeRoots": [
"node_modules/@types"
],
"types": [
"spotify-api"
],
{
"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
}
}
例如,Typescript找不到播放列表trackresponse
。我不明白为什么,因为它与其他项目中的类型(如@types/node
)的工作方式相同。我使用的是typescript 3.7.5
我的完整tsconfig.json
"typeRoots": [
"node_modules/@types"
],
"types": [
"spotify-api"
],
{
"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" />
如果您正在使用Nx Workspace,并且在创建库后遇到相同的错误。确保选中
tsconfig.app.json
并删除类型:[]
。它将覆盖使SpotifyApi命名空间“消失”的全局类型