From d0d3e35fa8d5e13a778816b6ab764b0b3210b8bb Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 19 Feb 2025 14:53:29 +0300 Subject: [PATCH 1/3] Use generated Options instead of Partial approach Signed-off-by: Sergey Malenkov --- arkoala/ets-plugin/src/StructTransformer.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arkoala/ets-plugin/src/StructTransformer.ts b/arkoala/ets-plugin/src/StructTransformer.ts index 289e041a3..7f93de0d3 100644 --- a/arkoala/ets-plugin/src/StructTransformer.ts +++ b/arkoala/ets-plugin/src/StructTransformer.ts @@ -667,13 +667,7 @@ export class StructTransformer extends AbstractVisitor { [ parameter( id("initializer"), - ts.factory.createTypeReferenceNode( - ts.factory.createIdentifier("Partial"), - [ts.factory.createTypeReferenceNode( - this.translateComponentName(adaptorClassName(node.name))!, - undefined - )] - ), + this.structOptions.createTypeReference(node), ts.factory.createObjectLiteralExpression() ) ], -- Gitee From 10935e3d68aa6bf90614935f1eedcfc8a6b6d60c Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 19 Feb 2025 14:57:13 +0300 Subject: [PATCH 2/3] canonize:all tests Signed-off-by: Sergey Malenkov --- arkoala/ets-plugin/test/golden/arkoala/ets/Rewrite.ts | 2 +- arkoala/ets-plugin/test/golden/arkoala/spec/@customDialog.ts | 2 +- .../test/golden/arkoala/spec/test/pages/import@CustomDialog.ts | 2 +- arkoala/ets-plugin/test/golden/arkts/ets/Rewrite.ts | 2 +- arkoala/ets-plugin/test/golden/arkts/spec/@customDialog.ts | 2 +- .../test/golden/arkts/spec/test/pages/import@CustomDialog.ts | 2 +- arkoala/ets-plugin/test/golden/koala/ets/Rewrite.ts | 2 +- arkoala/ets-plugin/test/golden/koala/spec/@customDialog.ts | 2 +- .../test/golden/koala/spec/test/pages/import@CustomDialog.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arkoala/ets-plugin/test/golden/arkoala/ets/Rewrite.ts b/arkoala/ets-plugin/test/golden/arkoala/ets/Rewrite.ts index 3e171348b..92e7c274d 100644 --- a/arkoala/ets-plugin/test/golden/arkoala/ets/Rewrite.ts +++ b/arkoala/ets-plugin/test/golden/arkoala/ets/Rewrite.ts @@ -875,7 +875,7 @@ export function CustomDialogExampleImpl(initializers?: CustomDialogExampleOption }; ArkCustomDialogExampleComponent._instantiate(undefined, () => new ArkCustomDialogExampleComponent, undefined, updatedInitializers); } -export function CustomDialogExample(initializer: Partial = {}) { +export function CustomDialogExample(initializer: CustomDialogExampleOptions = {}) { return { build: bindCustomDialog(CustomDialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/arkoala/spec/@customDialog.ts b/arkoala/ets-plugin/test/golden/arkoala/spec/@customDialog.ts index 4180f4500..4efc825eb 100644 --- a/arkoala/ets-plugin/test/golden/arkoala/spec/@customDialog.ts +++ b/arkoala/ets-plugin/test/golden/arkoala/spec/@customDialog.ts @@ -190,7 +190,7 @@ export function DialogExampleImpl(initializers?: DialogExampleOptions): void { }; ArkDialogExampleComponent._instantiate(undefined, () => new ArkDialogExampleComponent, undefined, updatedInitializers); } -export function DialogExample(initializer: Partial = {}) { +export function DialogExample(initializer: DialogExampleOptions = {}) { return { build: bindCustomDialog(DialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/arkoala/spec/test/pages/import@CustomDialog.ts b/arkoala/ets-plugin/test/golden/arkoala/spec/test/pages/import@CustomDialog.ts index 54ca1c411..62189f289 100644 --- a/arkoala/ets-plugin/test/golden/arkoala/spec/test/pages/import@CustomDialog.ts +++ b/arkoala/ets-plugin/test/golden/arkoala/spec/test/pages/import@CustomDialog.ts @@ -102,7 +102,7 @@ export function CustomDialogExample1Impl(initializers?: CustomDialogExample1Opti }; ArkCustomDialogExample1Component._instantiate(undefined, () => new ArkCustomDialogExample1Component, undefined, updatedInitializers); } -export function CustomDialogExample1(initializer: Partial = {}) { +export function CustomDialogExample1(initializer: CustomDialogExample1Options = {}) { return { build: bindCustomDialog(CustomDialogExample1Impl, initializer), buildOptions: initializer }; } export interface CustomDialogExample1Options { diff --git a/arkoala/ets-plugin/test/golden/arkts/ets/Rewrite.ts b/arkoala/ets-plugin/test/golden/arkts/ets/Rewrite.ts index 093fc0dce..c8b81391f 100644 --- a/arkoala/ets-plugin/test/golden/arkts/ets/Rewrite.ts +++ b/arkoala/ets-plugin/test/golden/arkts/ets/Rewrite.ts @@ -876,7 +876,7 @@ export function CustomDialogExampleImpl(initializers?: CustomDialogExampleOption }; ArkCustomDialogExampleComponent._instantiate(undefined, () => new ArkCustomDialogExampleComponent, undefined, updatedInitializers); } -export function CustomDialogExample(initializer: Partial = {}) { +export function CustomDialogExample(initializer: CustomDialogExampleOptions = {}) { return { build: bindCustomDialog(CustomDialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/arkts/spec/@customDialog.ts b/arkoala/ets-plugin/test/golden/arkts/spec/@customDialog.ts index 32f190e27..2ee1bfc8f 100644 --- a/arkoala/ets-plugin/test/golden/arkts/spec/@customDialog.ts +++ b/arkoala/ets-plugin/test/golden/arkts/spec/@customDialog.ts @@ -192,7 +192,7 @@ export function DialogExampleImpl(initializers?: DialogExampleOptions): void { }; ArkDialogExampleComponent._instantiate(undefined, () => new ArkDialogExampleComponent, undefined, updatedInitializers); } -export function DialogExample(initializer: Partial = {}) { +export function DialogExample(initializer: DialogExampleOptions = {}) { return { build: bindCustomDialog(DialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/arkts/spec/test/pages/import@CustomDialog.ts b/arkoala/ets-plugin/test/golden/arkts/spec/test/pages/import@CustomDialog.ts index 22be2c938..a5c169cc6 100644 --- a/arkoala/ets-plugin/test/golden/arkts/spec/test/pages/import@CustomDialog.ts +++ b/arkoala/ets-plugin/test/golden/arkts/spec/test/pages/import@CustomDialog.ts @@ -105,7 +105,7 @@ export function CustomDialogExample1Impl(initializers?: CustomDialogExample1Opti }; ArkCustomDialogExample1Component._instantiate(undefined, () => new ArkCustomDialogExample1Component, undefined, updatedInitializers); } -export function CustomDialogExample1(initializer: Partial = {}) { +export function CustomDialogExample1(initializer: CustomDialogExample1Options = {}) { return { build: bindCustomDialog(CustomDialogExample1Impl, initializer), buildOptions: initializer }; } export interface CustomDialogExample1Options { diff --git a/arkoala/ets-plugin/test/golden/koala/ets/Rewrite.ts b/arkoala/ets-plugin/test/golden/koala/ets/Rewrite.ts index c05169dbb..86c02fb02 100644 --- a/arkoala/ets-plugin/test/golden/koala/ets/Rewrite.ts +++ b/arkoala/ets-plugin/test/golden/koala/ets/Rewrite.ts @@ -873,7 +873,7 @@ export function CustomDialogExampleImpl(initializers?: CustomDialogExampleOption }; ArkCustomDialogExampleComponent._instantiate(undefined, () => new ArkCustomDialogExampleComponent, undefined, updatedInitializers); } -export function CustomDialogExample(initializer: Partial = {}) { +export function CustomDialogExample(initializer: CustomDialogExampleOptions = {}) { return { build: bindCustomDialog(CustomDialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/koala/spec/@customDialog.ts b/arkoala/ets-plugin/test/golden/koala/spec/@customDialog.ts index 6421236b7..e7de33702 100644 --- a/arkoala/ets-plugin/test/golden/koala/spec/@customDialog.ts +++ b/arkoala/ets-plugin/test/golden/koala/spec/@customDialog.ts @@ -192,7 +192,7 @@ export function DialogExampleImpl(initializers?: DialogExampleOptions): void { }; ArkDialogExampleComponent._instantiate(undefined, () => new ArkDialogExampleComponent, undefined, updatedInitializers); } -export function DialogExample(initializer: Partial = {}) { +export function DialogExample(initializer: DialogExampleOptions = {}) { return { build: bindCustomDialog(DialogExampleImpl, initializer), buildOptions: initializer }; } /** @memo */ diff --git a/arkoala/ets-plugin/test/golden/koala/spec/test/pages/import@CustomDialog.ts b/arkoala/ets-plugin/test/golden/koala/spec/test/pages/import@CustomDialog.ts index 3f0441a65..0e5828e7e 100644 --- a/arkoala/ets-plugin/test/golden/koala/spec/test/pages/import@CustomDialog.ts +++ b/arkoala/ets-plugin/test/golden/koala/spec/test/pages/import@CustomDialog.ts @@ -104,7 +104,7 @@ export function CustomDialogExample1Impl(initializers?: CustomDialogExample1Opti }; ArkCustomDialogExample1Component._instantiate(undefined, () => new ArkCustomDialogExample1Component, undefined, updatedInitializers); } -export function CustomDialogExample1(initializer: Partial = {}) { +export function CustomDialogExample1(initializer: CustomDialogExample1Options = {}) { return { build: bindCustomDialog(CustomDialogExample1Impl, initializer), buildOptions: initializer }; } export interface CustomDialogExample1Options { -- Gitee From 3640465ad9ec8e95d1bfe36f72b31e341d06e271 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 19 Feb 2025 14:58:59 +0300 Subject: [PATCH 3/3] remove unused partial* from utils Signed-off-by: Sergey Malenkov --- arkoala/ets-plugin/src/ApiUtils.ts | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/arkoala/ets-plugin/src/ApiUtils.ts b/arkoala/ets-plugin/src/ApiUtils.ts index b469a9d12..b461bbaf4 100644 --- a/arkoala/ets-plugin/src/ApiUtils.ts +++ b/arkoala/ets-plugin/src/ApiUtils.ts @@ -104,24 +104,6 @@ export function undefinedValue(): ts.Expression { return ts.factory.createIdentifier("undefined") } -export function partialForName(className: string) { - return ts.factory.createTypeReferenceNode( - "Partial", - [ - ts.factory.createTypeReferenceNode(className) - ] - ) -} - -export function partial(className: ts.Identifier) { - return ts.factory.createTypeReferenceNode( - "Partial", - [ - ts.factory.createTypeReferenceNode(ts.idText(className)) - ] - ) -} - export function anyIfNoType(type: ts.TypeNode | undefined): ts.TypeNode { if (!type) return Any() return type -- Gitee