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] String enum in composition of many potentially not supported #116

Open
1 task done
tsteckenborn opened this issue Nov 27, 2023 · 3 comments · May be fixed by #356
Open
1 task done

[BUG] String enum in composition of many potentially not supported #116

tsteckenborn opened this issue Nov 27, 2023 · 3 comments · May be fixed by #356
Labels
bug Something isn't working keepalive Will not be closed by Stale bot

Comments

@tsteckenborn
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Nature of Your Project

TypeScript

Current Behavior

Given cds such as:

entity Something : cuid {
  taggedElements : Composition of many {
                                  hierarchyLevel : String enum {
                                    oneTaggedElementHierarchyLevel
                                  };
                              key elementGuid           : String;
                            };

The following type is generated:

export function _SomethingAspect<TBase extends new (...args: any[]) => object>(Base: TBase) {
  return class Something extends Base {
        taggedElements?: __.Composition.of.many<Array< {
  hierarchyLevel?: taggedElements_hierarchyLevel | null,
  elementGuid?: string,
}>>;
  };
}

Yet taggedElements_hierarchyLevel is not defined.

Expected Behavior

I would've expected taggedElements_hierarchyLevel to exist.

Steps To Reproduce

No response

Environment

- **OS**: Mac OS
- **Node**: v20.10.0
- **npm**: 10.2.3
- **cds-typer**: 0.12.0
- **cds**: 7.4.1

Repository Containing a Minimal Reproducible Example

No response

Anything else?

No response

@tsteckenborn tsteckenborn added bug Something isn't working new labels Nov 27, 2023
@daogrady daogrady removed the new label Dec 5, 2023
Copy link

github-actions bot commented Jan 4, 2024

This issue has not been updated in a while. If it is still relevant, please comment on it to keep it open. The issue will be closed soon if it remains inactive.

@github-actions github-actions bot added the stale label Jan 4, 2024
@daogrady daogrady added the keepalive Will not be closed by Stale bot label Jan 8, 2024
@github-actions github-actions bot removed the stale label Jan 8, 2024
@tsteckenborn
Copy link
Author

Potentially any updates on this? A first step could be just typing them as the base type, e.g. string for now?

@daogrady
Copy link
Contributor

daogrady commented Jan 29, 2024

Hi Tobias,

sorry for the long silence. I'm afraid there has been no work done on this issue so far.

I am actually wondering if this use case is valid. When I replace the inline enum with a named one, I am seeing an error:

type hierarchyLevel: String enum {
  oneTaggedElementHierarchyLevel
}

entity Something {
  key elementGuid: String;
  taggedElements: Composition of many hierarchyLevel  // Expecting an entity or aspect as composition targetCDS (compiler)(ref-invalid-target)
}

It reads like the same should apply for inline-defined enums. So it kind of reads like your example should already be rejected by the compiler. I will investigate on this.

Best
Daniel

EDIT: I have misread your initial example, thanks for pointing that out. The following code works as expected:

type hierarchyLevel: String enum {
  oneTaggedElementHierarchyLevel
};

entity Something.taggedElements {
  hierarchyLevel: hierarchyLevel;
  key elementGuid: String;
}

entity Something {
  taggedElements: Composition of many Something.taggedElements
}

I can reproduce the issue. As users can use a named enum to work around this problem, I'd like to prioritise it fairly low. If you see an immediate solution and think this should be addressed asap, I would welcome any PR.

@stockbal stockbal linked a pull request Oct 12, 2024 that will close this issue
1 task
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants