Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
make ID constructor protected so it can't be constructed directly
Browse files Browse the repository at this point in the history
  • Loading branch information
zefir-git committed Jul 20, 2024
1 parent 551b58f commit 133f401
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class ID {
/**
* Create ID from the string representation of an ID.
*/
public constructor(id: string) {
protected constructor(id: string) {
this.#id = id;
}

Expand Down
4 changes: 4 additions & 0 deletions src/resource/Album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class Album extends ApiResource {

namespace Album {
export class ID extends ID_ {
public constructor(id: string) {
super(id);
}

public static override of(name: string, artist: Artist.ID): ID {
return super.of(name, artist.id);
}
Expand Down
4 changes: 4 additions & 0 deletions src/resource/Artist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Artist extends ApiResource {

namespace Artist {
export class ID extends ID_ {
public constructor(id: string) {
super(id);
}

public static override of(name: string): ID {
return super.of(name);
}
Expand Down
4 changes: 4 additions & 0 deletions src/resource/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class Track extends ApiResource {

namespace Track {
export class ID extends ID_ {
public constructor(id: string) {
super(id);
}

public static override of(title: string, artist: Artist.ID, album?: Album.ID | null): ID {
return super.of(title, artist.id, album?.id);
}
Expand Down

0 comments on commit 133f401

Please sign in to comment.