Open vc10812 opened 2 months ago
Hi @vc10812,
Can you please share the steps to reproduce the issue?
[Using TypeScript | capire (cloud.sap)](https://cap.cloud.sap/docs/node.js/typescript)
https://cap.cloud.sap/docs/tools/cds-typer
Based on the above documents, it is necessary to set up cds-typer and TypeScript. Additionally, you need to create custom services for the services in TypeScript
https://github.com/SAP-archive/btp-full-stack-typescript-app.
I believe you can reproduce the issue by adding cds-typer and attachments to the above sample code and adding TypeScript code.
Hi @vc10812,
I was investigating this issue with this cds and noted the following:
entity Books {
key ID: Integer;
reviews: Composition of many Attachments;
check: Composition of many b;
}
entity b{
key ID: Integer;
...
}
When in cds:
Composition of many Attachments
is being defined, the typescript generated has :
__.Composition.of.many<Attachments>
where Attachments is not getting resolved, and hence throwing an error.
Whereas, when an entity is being used instead:
Composition of many b
in ts:
__.Composition.of.many<b_>
gets generated where
b_ : class b_ extends Array<b> {$count?: number}
definition is there.
The same definition is missing in case of aspects
Since, for any aspect, the case is same, you can raise the issue here: https://github.com/cap-js/cds-typer/issues
As described in the link https://github.com/cap-js/attachments?tab=readme-ov-file#use-attachments, I set up Attachments, but there was an issue where TypeScript code generated by cds-typer resulted in errors and could not compile.
Therefore, by adding an entity as shown below, the issue was resolved.
The cause might be that specifying the aspect directly as Composition was the issue. Is it possible to fix it so that no errors occur?