Просмотр исходного кода

fix(compiler): using guard instead of non-nullish assertion (#13982)

沈青川 5 месяцев назад
Родитель
Сommit
dcc6f36257
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      packages/compiler-core/src/transforms/transformVBindShorthand.ts

+ 3 - 2
packages/compiler-core/src/transforms/transformVBindShorthand.ts

@@ -19,9 +19,10 @@ export const transformVBindShorthand: NodeTransform = (node, context) => {
           // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
           (__BROWSER__ &&
             prop.exp.type === NodeTypes.SIMPLE_EXPRESSION &&
-            !prop.exp.content.trim()))
+            !prop.exp.content.trim())) &&
+        prop.arg
       ) {
-        const arg = prop.arg!
+        const arg = prop.arg
         if (arg.type !== NodeTypes.SIMPLE_EXPRESSION || !arg.isStatic) {
           // only simple expression is allowed for same-name shorthand
           context.onError(