Skip to content

Commit

Permalink
feat: rename 'variations' to 'overloads'; suppress implementation sig…
Browse files Browse the repository at this point in the history
…nature
  • Loading branch information
codeworrior committed Oct 3, 2024
1 parent 908af14 commit ebda152
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
17 changes: 13 additions & 4 deletions packages/dts-generator/src/phases/dts-code-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,13 @@ function genMethodOrFunction(
? ""
: `<${_.map(ast.typeParameters, genTypeParameter).join(",")}>`;
let text = "";
if (ast.variations) {
if (ast.overloads) {
text += _.map(
ast.variations,
(variation) =>
genMethodOrFunction(variation, staticPossible, isFunc, options) + NL,
ast.overloads,
(overload) =>
genMethodOrFunction(overload, staticPossible, isFunc, options) + NL,
).join("");
return text;
}
text += JSDOC(ast) + NL;
text += applyTsIgnore(ast);
Expand Down Expand Up @@ -578,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
4 changes: 2 additions & 2 deletions packages/dts-generator/src/phases/json-fixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ function parseTypeExpressions(symbols: ConcreteSymbol[]) {
if (Array.isArray(method.throws)) {
method.throws.forEach(visitAnythingWithAType);
}
if (Array.isArray(method.variations)) {
method.variations.forEach(visitMethod);
if (Array.isArray(method.overloads)) {
method.overloads.forEach(visitMethod);
}
}

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

0 comments on commit ebda152

Please sign in to comment.