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] Generation fails if an entity is named "Record" #445

Open
1 task done
Kyrodan opened this issue Dec 19, 2024 · 1 comment
Open
1 task done

[BUG] Generation fails if an entity is named "Record" #445

Kyrodan opened this issue Dec 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working keepalive Will not be closed by Stale bot new

Comments

@Kyrodan
Copy link

Kyrodan commented Dec 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Nature of Your Project

TypeScript

Current Behavior

I have a CDS file in which I declare an Entity named "Record".
If I run cds-typer, then an exception occurs:

***masked*** error TS2315: Type 'Record' is not generic.
at Plugin.build (***masked***\node_modules\@cap-js\cds-typer\cds-plugin.js:139:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async Promise.allSettled (index 0)
    at async BuildTaskEngine._executePipeline (***masked***\node_modules\@sap\cds-dk\lib\build\buildTaskEngine.js:159:29)
    at async BuildTaskEngine._executeBuildTasks (***masked***\node_modules\@sap\cds-dk\lib\build\buildTaskEngine.js:150:25)
    at async BuildTaskEngine.processTasks (***masked***\node_modules\@sap\cds-dk\lib\build\buildTaskEngine.js:59:33)
    at async build (***masked***\node_modules\@sap\cds-dk\lib\build\index.js:19:16)
    at async Object.build (***masked***\node_modules\@sap\cds-dk\bin\build.js:171:5)
    at async Object.exec (***masked***\node_modules\@sap\cds-dk\bin\cds.js:91:16)

The generated Code looks like this:

export class Record extends _RecordAspect(__.Entity) {}
Object.defineProperty(Record, 'name', { value: 'srv.Records' })
Object.defineProperty(Record, 'is_singular', { value: true })
export class Records extends Array<Record> {$count?: number}
Object.defineProperty(Records, 'name', { value: 'srv.Records' })

This defined class "Record" overwrites the TypeScript Record type.
This leads to the TS-Error because the "wrong" Record will be used.

Expected Behavior

I can define a CDS-Entity named "Record" and the TS-Code ist generated correctly.

Steps To Reproduce

  1. Use code:
entity srv.Record {
  bar: String;
}
  1. run cds-typer on this code

Environment

- **OS**: Windows 11
- **Node**: 22.12.0
- **npm**: 10.9.0
- **cds-typer**: 0.31.0
- **cds**: 8.4.1

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

@Kyrodan Kyrodan added bug Something isn't working new labels Dec 19, 2024
@daogrady
Copy link
Contributor

Hi Daniel,

thanks for reporting this bug. I will look into it, but it will probably not happen before 2025. 🎄

Best,
Daniel

@daogrady daogrady self-assigned this Dec 19, 2024
@daogrady daogrady added the keepalive Will not be closed by Stale bot label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keepalive Will not be closed by Stale bot new
Projects
None yet
Development

No branches or pull requests

2 participants