Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ts-interface-generator): fix return type of removeAggregation #471

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
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