From 9250870e02c8004cb52cd83ce1b1fb1916736a63 Mon Sep 17 00:00:00 2001 From: Siriwat K Date: Thu, 1 Feb 2024 12:39:44 +0700 Subject: [PATCH] [zero] Always replace the `createUseThemeProps` call (#40885) --- .../src/processors/createUseThemeProps.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/zero-runtime/src/processors/createUseThemeProps.ts b/packages/zero-runtime/src/processors/createUseThemeProps.ts index 381285222dd683..dbdd445c57be5e 100644 --- a/packages/zero-runtime/src/processors/createUseThemeProps.ts +++ b/packages/zero-runtime/src/processors/createUseThemeProps.ts @@ -44,21 +44,17 @@ export class CreateUseThemePropsProcessor extends BaseProcessor { const t = this.astService; const { themeArgs: { theme } = {} } = this.options as IOptions; - if (!theme?.components?.[this.componentName]?.defaultProps) { - return; - } const useThemePropsImportIdentifier = t.addNamedImport( this.tagSource.imported, process.env.PACKAGE_NAME as string, ); - this.replacer( - t.callExpression(useThemePropsImportIdentifier, [ - valueToLiteral(theme.components[this.componentName].defaultProps), - ]), - true, - ); + let replacement: Expression = t.stringLiteral(this.componentName); + if (theme?.components?.[this.componentName]?.defaultProps) { + replacement = valueToLiteral(theme.components[this.componentName].defaultProps); + } + this.replacer(t.callExpression(useThemePropsImportIdentifier, [replacement]), true); } public override get asSelector(): string {