Skip to content

Wrong AddTrack type definition #2523

@aayla-secura

Description

@aayla-secura

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions