Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plural.drafts could be typeof Plural #163

Closed
daogrady opened this issue Feb 21, 2024 · 2 comments · Fixed by #354 · May be fixed by #192
Closed

Plural.drafts could be typeof Plural #163

daogrady opened this issue Feb 21, 2024 · 2 comments · Fixed by #354 · May be fixed by #192
Labels
feature request New feature or request good first issue Good for newcomers

Comments

@daogrady
Copy link
Contributor

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 daogrady added feature request New feature or request good first issue Good for newcomers new labels Feb 21, 2024
@daogrady daogrady removed the new label Mar 4, 2024
@geert-janklaps
Copy link

Hi @daogrady,

This actually is causing issues when registering handlers, if you register the handler with the plural of the drafts it's typed as an object. At runtime the value is not an object but an array.
image

Cheers,
Geert-Jan

geert-janklaps added a commit to geert-janklaps/cds-typer that referenced this issue Apr 4, 2024
@geert-janklaps
Copy link

Pull request #192 created to resolve this issue. (ran unit tests & did the same manual change in my running project to validate)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request good first issue Good for newcomers
Projects
None yet
2 participants