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] Inheritance only works for Aspects, not for Types #149

Closed
1 task done
willemi069808 opened this issue Jan 25, 2024 · 2 comments · Fixed by #150
Closed
1 task done

[BUG] Inheritance only works for Aspects, not for Types #149

willemi069808 opened this issue Jan 25, 2024 · 2 comments · Fixed by #150
Assignees
Labels
bug Something isn't working new

Comments

@willemi069808
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Nature of Your Project

TypeScript

Current Behavior

The below code defines an aspect and a type, and subsequently creates two entities that inherit from them. The inheritance from the type will throw a typescript error.

Expected Behavior

To be able to inherit both from aspects as well as types. Types allow for re-using the data structure as an entity property data type so it would be useful to have this.

Steps To Reproduce

schema.cds file:

namespace db;

aspect myAspect {
  name : Stringtype myType {
  name : Stringentity E_fromAspect : myAspect {} // works
entity E_fromType : myType {}     // fails

service.cds file:

service MyService {
  entity E_fromAspect as projection on db.E_fromAspect;
  entity E_fromType as projection on db.E_fromType;
}

service.ts file:

import { E_fromAspect, E_fromType } from '#cds-models/MyService'

Error from running tsc:

@cds-models/db/index.ts:32:33 - error TS2304: Cannot find name '_myTypeAspect'.
export class E_fromType extends _myTypeAspect(_E_fromTypeAspect(__.Entity)) {}

@cds-models/MyService/index.ts:22:37 - error TS2339: Property '_myTypeAspect' does not exist on type 'typeof import("...")'.
export class E_fromType extends _db._myTypeAspect(_E_fromTypeAspect(__.Entity)) {}

Found 2 errors in 2 files.
Errors Files
@cds-models/db/index.ts: 32
@cds-models/MyService/index.ts: 22

Environment

- **OS**: MacOS
- **Node**: 20.11.0
- **npm**: 10.2.4
- **cds-typer**: 0.15.0
- **cds**: 7.5.3

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

@willemi069808 willemi069808 added bug Something isn't working new labels Jan 25, 2024
@daogrady
Copy link
Contributor

Hi Willem,

thanks for reporting this issue! As it turns out, this issue is actually remotely related to another bug which I will address in a PR. I checked the sample you provided and found that it fixes the problem. Would you mind checking the PR on your actual model, so we can close this problem en passant if it turns out to fix the issue?

Best,
Daniel

@willemi069808
Copy link
Author

Hi Daniel,
A first test indicates that this PR indeed resolves the issue.
Thanks!

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