From 6e91245a56d0aef2eeb287b0dbce914abc3fa666 Mon Sep 17 00:00:00 2001 From: Kael Date: Sun, 5 Sep 2021 23:03:00 +1000 Subject: [PATCH] refactor: use proper type guards --- packages/babel-plugin-jsx/src/transform-vue-jsx.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts index 919a54e..ce7588b 100644 --- a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts +++ b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts @@ -288,16 +288,16 @@ const buildProps = (path: NodePath, state: State) => { propsExpression = t.objectExpression(dedupeProperties(properties, mergeProps)); if (optimize) { if (hasClassBinding) { - const klass = (propsExpression.properties as t.ObjectProperty[]) - .find((prop) => 'value' in prop.key && prop.key.value === 'class'); - if (klass?.type === 'ObjectProperty') { + const klass = propsExpression.properties + .find((prop) => t.isObjectProperty(prop) && t.isStringLiteral(prop.key) && prop.key.value === 'class'); + if (t.isObjectProperty(klass)) { klass.value = t.callExpression(createIdentifier(state, 'normalizeClass'), [klass.value as any]); } } if (hasStyleBinding) { - const style = (propsExpression.properties as t.ObjectProperty[]) - .find((prop) => 'value' in prop.key && prop.key.value === 'style'); - if (style?.type === 'ObjectProperty') { + const style = propsExpression.properties + .find((prop) => t.isObjectProperty(prop) && t.isStringLiteral(prop.key) && prop.key.value === 'style'); + if (t.isObjectProperty(style)) { style.value = t.callExpression(createIdentifier(state, 'normalizeStyle'), [style.value as any]); } }