Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "root",
"private": true,
"packageManager": "yarn@1.22.22",
"workspaces": {
"packages": [
"packages/*",
Expand Down
16 changes: 16 additions & 0 deletions packages/dts-generator/src/phases/dts-code-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,14 @@ function genMethodOrFunction(
? ""
: `<${_.map(ast.typeParameters, genTypeParameter).join(",")}>`;
let text = "";
if (ast.overloads) {
text += _.map(
ast.overloads,
(overload) =>
genMethodOrFunction(overload, staticPossible, isFunc, options) + NL,
).join("");
return text;
}
text += JSDOC(ast) + NL;
text += applyTsIgnore(ast);
text += ast.overwrite ? "// @ts-ignore" + NL : "";
Expand All @@ -571,6 +579,14 @@ function genMethodOrFunction(
function genConstructor(ast: FunctionDesc) {
let text = "";

if (ast.overloads) {
text += _.map(
ast.overloads,
(overload) => genConstructor(overload) + NL,
).join("");
return text;
}

text += JSDOC(ast) + NL;
text += ast.overwrite ? "// @ts-ignore" + NL : "";
text += ast.visibility === "protected" ? "protected " : ""; // only needed for hiding constructors via @hideconstructor
Expand Down
3 changes: 3 additions & 0 deletions packages/dts-generator/src/phases/json-fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ function parseTypeExpressions(symbols: ConcreteSymbol[]) {
if (Array.isArray(method.throws)) {
method.throws.forEach(visitAnythingWithAType);
}
if (Array.isArray(method.overloads)) {
method.overloads.forEach(visitMethod);
}
}

function visitEvent(event: Ui5Event) {
Expand Down
7 changes: 7 additions & 0 deletions packages/dts-generator/src/phases/json-to-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ class ASTVisitor {
* @param fct
*/
_visitFunction(fct: FunctionDesc) {
if (fct.overloads) {
_.forEach(fct.overloads, (overload) => this._visitFunction(overload));
}
_.forEach(fct.typeParameters, (typeParam) =>
this._visitTypeParam(typeParam),
);
Expand Down Expand Up @@ -1265,6 +1268,7 @@ function buildFunction(ui5Method: ObjMethod): FunctionDesc {
assertKnownProps(
[
"name",
"overloads",
"typeParameters",
"parameters",
"returnValue",
Expand All @@ -1277,6 +1281,9 @@ function buildFunction(ui5Method: ObjMethod): FunctionDesc {
const astNode: FunctionDesc = {
kind: "FunctionDesc",
name: ui5Method.name,
overloads: ui5Method.overloads
? _.map(ui5Method.overloads, buildFunction)
: undefined,
static: ui5Method.static === true,
typeParameters: _.map(ui5Method.typeParameters, buildTypeParameter),
parameters: _.map(ui5Method.parameters, buildParameter),
Expand Down
1 change: 1 addition & 0 deletions packages/dts-generator/src/types/ast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export interface VariableWithValue extends Variable {
export interface FunctionDesc extends AstNode, UI5JSDocs {
kind: "FunctionDesc";
name: string;
overloads?: Array<FunctionDesc>;
static?: boolean;
overwrite?: boolean;
typeParameters?: TypeParameter[];
Expand Down