JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API
https://jmperezperez.com/spotify-web-api-js/
MIT License
1.87k stars 260 forks source link

Add function overloading for typings in getUserPlaylists - Fixes #135 #156

Closed JMPerez closed 4 years ago

JMPerez commented 4 years ago

The getUserPlaylists function checks if the first parameter is a string, in which case it uses it as the userId, otherwise it assumes the request is for the current user and considers the input parameters as options and callback.

Passing undefined as userId assumes that the first parameter is options, but the code removes the first parameter.

Typescript supports the definition for function overloading, which is what's needed here https://www.typescriptlang.org/docs/handbook/functions.html#overloads

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 98.396% when pulling 16432e5a2444f4d05c37b86c597a457e20a24a06 on getUserPlaylists-typings into 0fa940eefb9ff3c1eec57218c9cc3c0af6342238 on master.