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

[BUG] Generated index.ts files have syntax errors "property '_...Aspect' does not exist" #270

Closed
1 task done
D027152 opened this issue Jul 4, 2024 · 10 comments · Fixed by #275
Closed
1 task done
Labels
bug Something isn't working new

Comments

@D027152
Copy link

D027152 commented Jul 4, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Nature of Your Project

TypeScript

Current Behavior

In our project we have defined the aspect SourceReferences, which is used in several entities.
The generated index.ts files containing these entities have al the syntax error

Property '_SourceReferenceAspect' does not exist on type 'typeof import("...

Somehow the index.ts files for the aspect seems not to be correctly generated.

Expected Behavior

The generated index.ts files shall be syntax error free.

Steps To Reproduce

repo https://github.tools.sap/erp4sme/crypto-for-business
npm run cds-typer:dev generates the files into folder @cap-models
Note: this script makes use of --IEEE754Compatible true in order to get cds type Decimal generated as (number | string)

Environment

| @cap-js/audit-logging  | 0.6.0                                         |
| @cap-js/cds-typer      | 0.21.2                                        |
| @cap-js/cds-types      | 0.2.0                                         |
| @cap-js/change-trackin | 1.0.5                                         |
| @cap-js/telemetry      | 0.1.0                                         |
| @sap/cds               | 7.7.3                                         |
| @sap/cds-common-conten | 1.4.0                                         |
| @sap/cds-compiler      | 4.8.0                                         |
| @sap/cds-dk            | 7.7.2                                         |
| @sap/cds-dk (global)   | 7.7.2                                         |
| @sap/cds-fiori         | 1.2.3                                         |
| @sap/cds-foss          | 5.0.0                                         |
| @sap/cds-mtxs          | 1.17.0                                        |
| @sap/eslint-plugin-cds | 2.6.7                                         |
| Node.js                | v18.18.0                                      |
| home                   | dch/crypto-for-business/node_modules/@sap/cds |

Repository Containing a Minimal Reproducible Example

https://github.tools.sap/erp4sme/crypto-for-business
branch switch-to-cds-typer-payment-master-data
aspect SourceReferences is defined here: db/masterData/common/SourceReferences.cds

Anything else?

No response

@D027152 D027152 added bug Something isn't working new labels Jul 4, 2024
@D027152
Copy link
Author

D027152 commented Jul 16, 2024

Are there any comments on my problem?

@daogrady
Copy link
Contributor

Hi Stefan,

sorry for the wait, I was OOO.
I can confirm the problem you described. There appears to be some incorrect aspect naming going on (should be _SourceReferencesAspect, but is generated as _SourceReferencesAspect).

I will look into it.

Best,
Daniel

@daogrady
Copy link
Contributor

I have prepared a fix for this. Would you like to check if it works for your model before I release it?

@D027152
Copy link
Author

D027152 commented Jul 17, 2024

I would like to do so, but I am not sure what I have to do in order to link our repo to the feature branch of your repo. I assume this is possible, but I have never done this. If you tell me what I have to do I can give it a try.

@daogrady
Copy link
Contributor

daogrady commented Jul 17, 2024

Sorry, I should have led with that! Please find this guide attached. If you need any further assistance in setting it up, just let me know.

@D027152
Copy link
Author

D027152 commented Jul 17, 2024

Thank you for the guide, I was able to follow the steps and hopefully did everything correctly.

Unfortunately, the correction seems not to work for me. The generated files look different, but still contain a syntax error.

See this example:

Before:
image

With the correction from feature branch fix/singular-aspects
image

@daogrady
Copy link
Contributor

Could you please add the error message you are seeing there?
Can you please also check @cds-models/sap/erp4sme/c4b/masterData/common/index.ts contains a export function _SourceReferenceAspect (singular! Not export function _SourceReferencesAspect plural). That appeared to be the problem that shold have been fixed.

@D027152
Copy link
Author

D027152 commented Jul 18, 2024

Hi Daniel

I just re-generated the files in @cds-models with the local link to your feature branch.
I confirm that @cds-models/sap/erp4sme/c4b/masterData/common/index.ts contains an export function _SourceReferenceAspect (singular). There is no longer a syntax error in the file mentioned above (@cds-models/BusinessPartnerUiService/index.ts). I don't know why I did see different result yesterday. Anyway, your fix for this problem seems to work! Thank you.

I checked now all generated files in @cds-models for further syntax errors. Unfortunately, I found the following additional ones:

The error

Property 'Integration' in type '(Anonymous class)' is not assignable to the same property in base type '_cuidAspect<{ new (...args: any[]): _managedAspect<{ new (...args: any[]): _SourceReferenceAspect<TBase>.(Anonymous class); prototype: _SourceReferenceAspect<any>.(Anonymous class); readonly actions: Record<...>; } & TBase>.(Anonymous class); prototype: _managedAspect<...>.(Anonymous class); readonly actions: Record...'. Type 'string' has no properties in common with type 'Integration'.

occurs in the files

  • @cds-models/sap/erp4sme/c4b/payment/payables/index.ts
  • @cds-models/sap/erp4sme/c4b/payment/receivables/index.ts
  • @cds-models/sap/erp4sme/c4b/payment/paymentOrders/index.ts
  • @cds-models/sap/erp4sme/c4b/payment/clearings/index.ts
  • @cds-models/sap/erp4sme/c4b/masterData/businessPartners/index.ts

Several additional errors, like e.g.

Cannot redeclare exported variable '_PaymentAgreementOutgoingAspect'.
Cannot redeclare exported variable '_PaymentAgreementIncomingAspect'.
Class 'PaymentAgreementIncoming' used before its declaration.

occur in the file

  • @cds-models/sap/erp4sme/c4b/masterData/businessPartners/index.ts

I have pushed these in the branch switch-to-cds-typer-payment-master-data (see https://github.tools.sap/erp4sme/crypto-for-business/tree/switch-to-cds-typer-payment-master-data/%40cds-models)

Shall I open a separate bug for these, or can you check further in within this bug?

Thank you,
Stefan

@daogrady
Copy link
Contributor

Hi Stefan,

guess there was some caching or stale files going on, no worries. 🙂
I noticed these other errors as well and they look like a bigger problem. I would prefer to first get this PR in and push out a release asap and maybe attack this new issue in a follow up. So if you could just open a new issue for this other problem, that would be great!

Best,
Daniel

@D027152
Copy link
Author

D027152 commented Jul 18, 2024

I created #278 as follow-up for the new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants