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.
Coverage remained the same at 98.396% when pulling 16432e5a2444f4d05c37b86c597a457e20a24a06 on getUserPlaylists-typings into 0fa940eefb9ff3c1eec57218c9cc3c0af6342238 on master.
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 asoptions
andcallback
.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