Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCurrentlyPlayingTrack returns string if nothing is currently playing. #22

Closed
patrick-motard opened this issue Feb 4, 2021 · 1 comment · Fixed by #23
Closed

getCurrentlyPlayingTrack returns string if nothing is currently playing. #22

patrick-motard opened this issue Feb 4, 2021 · 1 comment · Fixed by #23
Labels

Comments

@patrick-motard
Copy link
Contributor

patrick-motard commented Feb 4, 2021

let track = await this.spotify.client.player.getCurrentlyPlayingTrack();
console.log(typeof track)
// outputs: string
if (track === '') {
      console.log('nothing playing currently');

      return;
}

Editor gives the following warning:

This condition will always return 'false' since the types 'CurrentlyPlaying' and 'string' have no overlap.ts(2367)

Code works at runtime because the function is returning a string when nothing is playing. I think it should return undefined, or an error, or a status code, to indicate that nothing is playing, and it should indicate that return type in the signature so that typescript doesn't freak out.

patrick-motard added a commit to patrick-motard/spotify-web-api-ts that referenced this issue Feb 7, 2021
`getCurrentlyPlayingTrack` returns an empty string if no song is currently
playing. The type response of that function is incorrect, leading to
complile errors. This PR fixes the issue by correcting the type
response.

Fixes adamgrieger#22
patrick-motard added a commit to patrick-motard/spotify-web-api-ts that referenced this issue Feb 10, 2021
`getCurrentlyPlayingTrack` returns an empty string if no song is currently
playing. The type response of that function is incorrect, leading to
complile errors. This PR fixes the issue by correcting the type
response.

Fixes adamgrieger#22
adamgrieger pushed a commit that referenced this issue Feb 11, 2021
`getCurrentlyPlayingTrack` returns an empty string if no song is currently
playing. The type response of that function is incorrect, leading to
complile errors. This PR fixes the issue by correcting the type
response.

Fixes #22
@adamgrieger
Copy link
Owner

🎉 This issue has been resolved in version 1.4.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

thomas-negrault pushed a commit to thomas-negrault/spotify-web-api-ts that referenced this issue Apr 10, 2022
`getCurrentlyPlayingTrack` returns an empty string if no song is currently
playing. The type response of that function is incorrect, leading to
complile errors. This PR fixes the issue by correcting the type
response.

Fixes adamgrieger#22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants