2

I installed @types/spotify-api and made the following changes to my tsconfig.json

"typeRoots": [
  "node_modules/@types"
],
"types": [
  "spotify-api"
],

Typescript can't find PlaylistTrackResponse for example. I can't figure out why because it works the same way with types like @types/node in other projects. I'm using typescript 3.7.5.

my full 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
  }
}

2 Answers 2

1

Don't know if you still need an answer to this since you asked the question quite a while ago but you can get around this by putting:

/// <reference types="spotify-api" />

at the top of your class and then getting any types like so:

SpotifyApi.PlaylistObjectSimplified
Sign up to request clarification or add additional context in comments.

Comments

0

If you are using Nx Workspace and are facing the same errors after creating a library. Make sure to check tsconfig.app.json and remove the types: []. It will overrides the global types thing which make SpotifyApi namespace "disappear"

Nx workspace library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.