Skip to content

Commit

Permalink
fix(ts-interface-generator): fix return type of removeAggregation (#471)
Browse files Browse the repository at this point in the history
fixes #470
  • Loading branch information
akudev authored Sep 10, 2024
1 parent aa36d21 commit 8164fb6
Show file tree
Hide file tree
Showing 8 changed files with 742 additions and 759 deletions.
2 changes: 1 addition & 1 deletion packages/ts-interface-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@types/hjson": "2.4.6",
"@types/jest": "29.5.12",
"@types/node": "20.14.9",
"@types/openui5": "1.117.0",
"@types/openui5": "1.127.0",
"@types/yargs": "17.0.32",
"@typescript-eslint/eslint-plugin": "7.14.1",
"@typescript-eslint/parser": "7.14.1",
Expand Down
11 changes: 10 additions & 1 deletion packages/ts-interface-generator/src/astGenerationHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,16 @@ function generateMethods(
]),
),
],
factory.createThisTypeNode(),
factory.createUnionTypeNode([
// the removed child or null if not found
createTSTypeNode(
aggregation.type,
requiredImports,
knownGlobals,
currentClassName,
),
factory.createLiteralTypeNode(ts.factory.createNull()),
]),
);
addJSDocCommentToNode(
remove,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test("Generate methods for aggregation", () => {
getContent(): Control[];
addContent(content: Control): this;
insertContent(content: Control, index: number): this;
removeContent(content: number | string | Control): this;
removeContent(content: number | string | Control): Control | null;
removeAllContent(): Control[];
indexOfContent(content: Control): number;
destroyContent(): this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ declare module "./SampleControl" {
* @param content The content to remove or its index or id
* @returns The removed content or "null"
*/
removeContent(content: number | string | Control): this;
removeContent(content: number | string | Control): Control | null;
/**
* Removes all the controls from the aggregation "content".
Expand Down Expand Up @@ -511,7 +511,7 @@ declare module "./SampleControl" {
* @param content The content to remove or its index or id
* @returns The removed content or "null"
*/
removeContent(content: number | string | Control): this;
removeContent(content: number | string | Control): Control | null;
/**
* Removes all the controls from the aggregation "content".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ declare module "./SampleControl" {
* @param content The content to remove or its index or id
* @returns The removed content or "null"
*/
removeContent(content: number | string | Control): this;
removeContent(content: number | string | Control): Control | null;

/**
* Removes all the controls from the aggregation "content".
Expand Down Expand Up @@ -465,7 +465,7 @@ declare module "./SampleControl" {
* @param content The content to remove or its index or id
* @returns The removed content or "null"
*/
removeContent(content: number | string | Control): this;
removeContent(content: number | string | Control): Control | null;

/**
* Removes all the controls from the aggregation "content".
Expand Down
Loading

0 comments on commit 8164fb6

Please sign in to comment.