react-native-track-player
react-native-track-player copied to clipboard
Wrong AddTrack type definition
Describe the Bug
AddTrack is defined as a union of Track and url and artwork properties which are meant to be string | ResourceObject. However because these properties exist in Track and are defined as string only, the effective type AddTrack["url"] and AddTrack["artwork"] is also string.
Code To Reproduce
const url: ResourceObject = require("something.mp3");
const artwork: ResourceObject = require("something.jpg");
const track: AddTrack = {
url, // error: Type 'number' is not assignable to type 'string'
artwork, // error: Type 'number' is not assignable to type 'string'
}
How I can Help
The correct definition for AddTrack should omit these properties from Track first, like so:
export type AddTrack = Omit<Track, "url" | "artwork"> & {
url: string | ResourceObject;
artwork?: string | ResourceObject;
};
Happy to review a pr for this
Happy to review a pr for this
Ok, submitted PR #2529