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

[SUGGESTION] Export interfaces instead of types to allow module augmentation #205

Open
aschmidt93 opened this issue Aug 21, 2024 · 0 comments

Comments

@aschmidt93
Copy link

This is a generalization of #185, where it was suggested to use an interface for cds_services. I'd like to suggest to expand this approach and apply it to other types, especially inline defined, too. This allows users to use module augmentation to improve the types in their projects.

Examples:

// currently
export const connect : {
  // ...
}
// suggested
export interface Connect {
 // ...
}

export const connect : Connect;

Example for possible module augmentation:

// index.d.ts

declare module '@sap/cds' {
  export interface Connect {
   // limit datasource to services available in the project
    to( datasource : 'myServiceA' | 'myServiceB', options? : cds_connect_options) : Promise<Service>;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant