cds-typer icon indicating copy to clipboard operation
cds-typer copied to clipboard

`Plural.drafts` could be `typeof Plural`

Open daogrady opened this issue 1 year ago • 2 comments

Currently, both the singular and the plural form of entities have a reference to .drafts. This makes sense as they point to the same CSN entity during runtime and should be treated the same. So:

class Singular {
  static drafts: typeof Singular
}

class Plural extends Array<Singular> {
  static drafts: typeof Singular
}

This leads to confusion when the type should not actually matter:

SELECT.from(b ? Plural : Plural.drafts)  // Singular | Plural -> no proper type support

Find out if there is a compelling argument against

class Plural extends Array<Singular> {
  static drafts: typeof Plural
}

and if not implement this behaviour.

daogrady avatar Feb 21 '24 12:02 daogrady