Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 打字脚本可以';在我的angular项目中找不到@types/spotify api_Typescript - Fatal编程技术网

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命名空间“消失”的全局类型