Skip to content

Commit

Permalink
feat(dts-generator): allow changing names in .dtsgenrc overlays (#464)
Browse files Browse the repository at this point in the history
...at least in deeper levels.
This is required for building type definitions where the pseudo
parameter "this" defines the type on which the method is called.
Declaring this in .dtsgenrc shifts the parameters from JSDoc by one.
Needed for full ControllerExtension support.
  • Loading branch information
akudev authored Jul 4, 2024
1 parent 4e71b69 commit 5d5e690
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/dts-generator/src/phases/json-fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ function mergeOverlays(apijson: ApiJSON, directives: Directives) {
obj[prop] = value;
}

function mergeProps(obj: { [key: string]: unknown }, overlay: object) {
function mergeProps(
obj: { [key: string]: unknown },
overlay: object,
preserveName?: boolean,
) {
Object.entries(overlay).forEach(([prop, value]) => {
if (prop !== "name") {
if (prop !== "name" || !preserveName) {
// only change name in deeper recursive calls where preserveName flag is not set anymore
mergeProp(obj, prop, value);
}
});
Expand Down Expand Up @@ -105,7 +110,7 @@ function mergeOverlays(apijson: ApiJSON, directives: Directives) {
symbolItems.push(overlayItem);
return;
}
mergeProps(item, overlayItem);
mergeProps(item, overlayItem, true /* preserveName */);
});
} else {
mergeProp(symbol, prop, overlay[prop]);
Expand Down

0 comments on commit 5d5e690

Please sign in to comment.