cancel
Showing results for 
Search instead for 
Did you mean: 

CAP 6.2.3 issues on Deep Read with Typescript

Andrew_Mai
Participant
0 Kudos

On CAP 6.2.3, if we use Deep READ:

SELECT.from(User)
    .columns((u) => {
        u('*')
        u.userGroupUsers((ugu) => {
            ugu('*')
        });
    })

We will get an error when compile the Typescript code:

Property userGroupUsers does not exits on type 'Definition'.

Hope we can update the Typescript Type for this one.

View Entire Topic
daniel_ogrady
Explorer
0 Kudos

Hi Andrew,

you are right, the types are lacking a bit of detail on the model side. We are currently looking into providing a solution for users that need types for their model – so stay tuned for that!

In the meantime, you could try to fool Typescript with the following:

SELECT.from(User)
    .columns((u) => {
        u('*')
        (u as unknown as User).userGroupUsers((ugu) => {
            ugu('*')
        });
    })

which should hopefully give you the desired results.

Best regards,
Daniel

Andrew_Mai
Participant
0 Kudos

Hi,

Can we at least make the type definition back to the way before, I'm having a hard time to upgrade new version @sap/cds because of this issues. Because there are a lot of code, and the above one is just a temporally solution.

daniel_ogrady
Explorer

Hi Andrew,

sorry to hear you are running into troubles during the update! I'm afraid I am not entirely clear on which behaviour you were encountering before the update. As far as I am aware, the new version was supposed to be backwards compatible in that regard.

Could you maybe provide us with more details as to what version of CDS you are upgrading from, what parts of the API you noticed to have changed, and maybe even a repository with a minimal reproducible example?

Best,
Daniel

Andrew_Mai
Participant
0 Kudos

Hi,

We have a lot of issues during the upgrade, not only the Definition, the most trouble for us is the .send API

https://cap.cloud.sap/docs/node.js/services#srvsend---method-path--query--event-data-headers---resul...

We following the same code on the above link, it's working fine on cds 5.9.8, but on cds 6.3.1, it will give this error:

No overload matches this call.
Overload 1 of 3, '(event: Events, data?: object, headers?: object): Promise<Transaction>', gave the following error.
Argument of type '{ method: string; path: string; data: { userID: any; convert: boolean; }; headers: { authorization: string; }; }' is not
assignable to parameter of type 'Events'

Thanks for sharing, i just adjusted the typings for that specific API. Could you still provide some samples where it happens, so i can confirm it is fixed? Thanks!