Skip to content

Commit 487c2c2

Browse files
committed
fix(dts-generator): support rest parameters in functions in nested types
When api.json contains: Object<string,function(...any)>|function Then the d.ts file will contain: Record<string, (...p1: any) => void> | Function; Before this fix, the function had no parameter.
1 parent b6c0fe5 commit 487c2c2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/dts-generator/src/phases/dts-code-gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ function genType(ast: Type, usage: string = "unknown"): string {
873873
if (!_.isEmpty(ast.typeParameters)) {
874874
text += `<${_.map(ast.typeParameters, (param) => param.name).join(", ")}>`; // TODO defaults, constraints, expressions
875875
}
876-
text += `(${_.map(ast.parameters, (param) => `${param.name}${param.optional ? "?" : ""}: ${genType(param.type, "parameter")}`).join(", ")})`;
876+
text += `(${_.map(ast.parameters, (param) => `${param.type?.repeatable ? "..." : ""}${param.name}${param.optional ? "?" : ""}: ${genType(param.type, "parameter")}`).join(", ")})`;
877877
text += ` => ${ast.type ? genType(ast.type, "returnValue") : "void"}`;
878878
return text;
879879
case "NativeTSTypeExpression":

test-packages/openui5-snapshot-test/input-sdk/sap.ui.core.api.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110776,14 +110776,14 @@
110776110776
},
110777110777
{
110778110778
"name": "actions",
110779-
"type": "Object<string,function()>|function",
110779+
"type": "Object<string,function(...any)>|function",
110780110780
"optional": true,
110781110781
"visibility": "public",
110782110782
"description": "A map or a class of functions that can be used as arrangement or action in Opa tests. Only the test decides whether a function is used as arrangement or action. Each function typically contains one or multiple <code>waitFor</code> statements."
110783110783
},
110784110784
{
110785110785
"name": "assertions",
110786-
"type": "Object<string,function()>|function",
110786+
"type": "Object<string,function(...any)>|function",
110787110787
"optional": true,
110788110788
"visibility": "public",
110789110789
"description": "A map or a class of functions that can be used as assertions in Opa tests."

test-packages/openui5-snapshot-test/output-dts/sap.ui.core.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83938,11 +83938,11 @@ declare module "sap/ui/test/Opa5" {
8393883938
* whether a function is used as arrangement or action. Each function typically contains one or multiple
8393983939
* `waitFor` statements.
8394083940
*/
83941-
actions?: Record<string, () => void> | Function;
83941+
actions?: Record<string, (...p1: any) => void> | Function;
8394283942
/**
8394383943
* A map or a class of functions that can be used as assertions in Opa tests.
8394483944
*/
83945-
assertions?: Record<string, () => void> | Function;
83945+
assertions?: Record<string, (...p1: any) => void> | Function;
8394683946
};
8394783947
}
8394883948

0 commit comments

Comments
 (0)