Open aschmidt93 opened 1 month ago
Hi Andreas,
thank you for your suggestion. I am actually not sure if module augmentation is the right approach here, as that is kind of a "last resort" technique and here it is used for added convenience. Wouldn't a helper type appropriately address the underlying issue?
Best, Daniel
cds.services
is currently typed as typecds_services
:export type cds_services = { [name: string]: Service }
. Types can not be extended via module augmentation, thus this does not work:cds.services
would still be typed as{ [name: string]: Service }
.In order for module augmentation to work,
cds_services
has to be an interface.Idea
Now module augmentation can be used to extend
cds_services
:Now,
cds.services.foo
is properly typed as "bar".Reason
This can be used to narrow down the type of
cds_services
to only those services that actually exist in the project. Additionally,cds-typer
can be used to type those services.