cap-js / cds-typer

CDS type generator for JavaScript
Apache License 2.0
29 stars 10 forks source link

[BUG] Missing draft in generated type for entity #302

Open FilipTLW opened 3 months ago

FilipTLW commented 3 months ago

Is there an existing issue for this?

Nature of Your Project

TypeScript

Current Behavior

I need to access the drafts object of an entity which is used as

Composition of many LimsPlanStepManValueSelectOptions on manValueSelect.parent = $self;

When using

await INSERT.into(LimsPlanStepManValueSelectOption.drafts, manValueSelectObjects)

I get the typescript error Property 'drafts' does not exist on type 'typeof LimsPlanStepManValueSelectOptions '. When trying to enable drafts on that entity I get the CAP error Composition in draft-enabled entity can't lead to another entity with “@odata.draft.enabled” (in entity:“LimsPlanService.LimsPlanStep”/element:“manValueSelect”)

The Typescript error can be avoided using // @ts-ignore which then results in expected behavior.

Expected Behavior

The Typescript definitions of models which are used as Compositions should include a drafts entity in order to be able to properly register event handlers or perform database operations on them, without using // @ts-ignore.

Steps To Reproduce

No response

Environment

- **OS**: Debian GNU/Linux 12 (bookworm) (SAP Business Aplication Studio)
- **Node**: v20.12.0
- **npm**: 10.5.0
- **cds-typer**: 0.25.0
- **cds**: 7.9.4

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

github-actions[bot] commented 1 month ago

This issue has not been updated in a while. If it is still relevant, please comment on it to keep it open. The issue will be closed soon if it remains inactive.