Skip to content

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

@aschmidt93

Description

@aschmidt93

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>;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions