You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TypeScript, when calling getUserPlaylists(), the options object is ignored when userId is passed as undefined.
constresult=awaitspotify.getUserPlaylists(undefined,{limit: 50});console.log(result.length);// <-- 20, the default limit
This is because the method getUserPlaylists() has dynamic behaviour, re-assigning its arguments if the first argument is not a string. The current types for getUserPlaylists() don't reflect this beahviour.
You could also make the types more accurate by using an interface instead of the catch-all Object type for the options, and distinguishing between the Promise-returning and callback versions of the method.
In TypeScript, when calling
getUserPlaylists()
, the options object is ignored whenuserId
is passed as undefined.This is because the method
getUserPlaylists()
has dynamic behaviour, re-assigning its arguments if the first argument is not a string. The current types forgetUserPlaylists()
don't reflect this beahviour.Code in question:
Types:
Possible fix
You could fix the types by overloading the function signature.
You could also make the types more accurate by using an interface instead of the catch-all
Object
type for the options, and distinguishing between the Promise-returning and callback versions of the method.The text was updated successfully, but these errors were encountered: