react-native-track-player icon indicating copy to clipboard operation
react-native-track-player copied to clipboard

Wrong AddTrack type definition

Open aayla-secura opened this issue 3 months ago • 2 comments

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;
};

aayla-secura avatar Sep 23 '25 09:09 aayla-secura

Happy to review a pr for this

puckey avatar Sep 23 '25 15:09 puckey

Happy to review a pr for this

Ok, submitted PR #2529

aayla-secura avatar Sep 26 '25 11:09 aayla-secura