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

[PROPOSAL] for interface name created for anonymous composition #22

Open
mocotrah opened this issue Jan 3, 2022 · 2 comments
Open

[PROPOSAL] for interface name created for anonymous composition #22

mocotrah opened this issue Jan 3, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@mocotrah
Copy link

mocotrah commented Jan 3, 2022

Given the following example:

entity Gathering {
  key id : String;
  employee :  Composition of {
                name : String
              };
}
entity Company {
  key id : String;
  companyName: String;
  employee :  Composition of {
                serialNumber : String;
                pointModel : String;
              };
}

after cds2types compilation, we'll find ourselves with 2 IEmployee interfaces

export interface IEmployee {
    up_?: IGathering;
    up__id?: string;
    name: string;
  }

  export interface IEmployee {
    up_?: ICompany;
    up__id?: string;
    serialNumber: string;
    pointModel: string;
  }

in the same namespace.
This will produce typescript compilation errors later.

Proposal
When generating the interface names for anonymous inline compositions, inject the entity name inside.
Example:
ICompanyEmployee
IGatheringEmployee

Proposal extension: use the same approach for anonymous inline type definitions

Example:

type OpeningTime {
  twentyFourBySeven   :      Boolean;
  regularHour        :  {
      begin   : String;
      end     : String;
      weekday : Integer;
    };
}

will produce:

export interface IOpeningTimeRegularHour {
    begin: string;
    end: string;
    weekday: number;
  }
export interface IOpeningTime {
    twentyFourBySeven: boolean;
    regularHours: IOpeningTimeRegularHour;
  }

Today, the cds2types rejects with an error, and force the developer to declare the inline type declaration as a separate type.

@HeneryHawk HeneryHawk added the enhancement New feature or request label Jan 4, 2022
@HeneryHawk
Copy link
Collaborator

Hi @mocotrah

Thanks for the proposal.
We will add this to our list, but we can't give any details by when and if we will implement this feature.

Regards
Simon

@mocotrah
Copy link
Author

Thanks for accepting the proposal.
I hope the proposal is correct, I'm new to CDS world... I have encountered the issue in my current project where we have a big data model and sometimes the interfaces are created with the same name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants