youtube-node
youtube-node copied to clipboard
Fix some unintentionally broken typings for callbacks
For the TypeScript definitions for this library, the function signature for the API calls that take a callback
argument seem to have been accidentally formatted incorrectly. That is, looking at search
, the signature should be:
function search(
id: string,
maxResults: number,
params: Object,
callback: (error?: Error, data?: YtResult) => void
);
However, the way it's currently written, it's interpreted as:
function search(
id: string,
maxResults: number,
params: Object,
callback: (error?: Error) => void,
data?: YtResult
);
It looked like in addition to search
, the same issue is also found on getPlaylistItemsById
and related
. In order to prevent this typo from happening again, I moved the whole function signature to its own type declaration so it's much simpler to use as a function argument.
Additionally, the search
function provides an overloaded signature that's used in the example documents, where params
is skipped and callback
becomes the third parameter. I've added this overloaded signature.