Skip to content

Commit 8164fb6

Browse files
authored
fix(ts-interface-generator): fix return type of removeAggregation (#471)
fixes #470
1 parent aa36d21 commit 8164fb6

File tree

8 files changed

+742
-759
lines changed

8 files changed

+742
-759
lines changed

packages/ts-interface-generator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@types/hjson": "2.4.6",
3939
"@types/jest": "29.5.12",
4040
"@types/node": "20.14.9",
41-
"@types/openui5": "1.117.0",
41+
"@types/openui5": "1.127.0",
4242
"@types/yargs": "17.0.32",
4343
"@typescript-eslint/eslint-plugin": "7.14.1",
4444
"@typescript-eslint/parser": "7.14.1",

packages/ts-interface-generator/src/astGenerationHelper.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,16 @@ function generateMethods(
579579
]),
580580
),
581581
],
582-
factory.createThisTypeNode(),
582+
factory.createUnionTypeNode([
583+
// the removed child or null if not found
584+
createTSTypeNode(
585+
aggregation.type,
586+
requiredImports,
587+
knownGlobals,
588+
currentClassName,
589+
),
590+
factory.createLiteralTypeNode(ts.factory.createNull()),
591+
]),
583592
);
584593
addJSDocCommentToNode(
585594
remove,

packages/ts-interface-generator/src/test/generateMethods.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test("Generate methods for aggregation", () => {
4040
getContent(): Control[];
4141
addContent(content: Control): this;
4242
insertContent(content: Control, index: number): this;
43-
removeContent(content: number | string | Control): this;
43+
removeContent(content: number | string | Control): Control | null;
4444
removeAllContent(): Control[];
4545
indexOfContent(content: Control): number;
4646
destroyContent(): this;

packages/ts-interface-generator/src/test/interfaceGenerationHelper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ declare module "./SampleControl" {
188188
* @param content The content to remove or its index or id
189189
* @returns The removed content or "null"
190190
*/
191-
removeContent(content: number | string | Control): this;
191+
removeContent(content: number | string | Control): Control | null;
192192
193193
/**
194194
* Removes all the controls from the aggregation "content".
@@ -511,7 +511,7 @@ declare module "./SampleControl" {
511511
* @param content The content to remove or its index or id
512512
* @returns The removed content or "null"
513513
*/
514-
removeContent(content: number | string | Control): this;
514+
removeContent(content: number | string | Control): Control | null;
515515
516516
/**
517517
* Removes all the controls from the aggregation "content".

packages/ts-interface-generator/src/test/testdata/sampleControl/SampleControl.gen.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ declare module "./SampleControl" {
142142
* @param content The content to remove or its index or id
143143
* @returns The removed content or "null"
144144
*/
145-
removeContent(content: number | string | Control): this;
145+
removeContent(content: number | string | Control): Control | null;
146146

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

470470
/**
471471
* Removes all the controls from the aggregation "content".

0 commit comments

Comments
 (0)