Browse Source

fix(compiler-sfc): infer runtime type in defineProps (#7972)

三咲智子 Kevin Deng 3 years ago
parent
commit
ba4cec31b9
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/compiler-sfc/src/compileScript.ts

+ 5 - 2
packages/compiler-sfc/src/compileScript.ts

@@ -2129,7 +2129,7 @@ function inferRuntimeType(
         case 'BigIntLiteral':
           return ['Number']
         default:
-          return [`UNKNOWN`]
+          return [UNKNOWN_TYPE]
       }
 
     case 'TSTypeReference':
@@ -2177,6 +2177,7 @@ function inferRuntimeType(
                 declaredTypes
               ).filter(t => t !== 'null')
             }
+            break
           case 'Extract':
             if (node.typeParameters && node.typeParameters.params[1]) {
               return inferRuntimeType(
@@ -2184,6 +2185,7 @@ function inferRuntimeType(
                 declaredTypes
               )
             }
+            break
           case 'Exclude':
           case 'OmitThisParameter':
             if (node.typeParameters && node.typeParameters.params[0]) {
@@ -2192,9 +2194,10 @@ function inferRuntimeType(
                 declaredTypes
               )
             }
-          // cannot infer, fallback to UNKNOWN: ThisParameterType
+            break
         }
       }
+      // cannot infer, fallback to UNKNOWN: ThisParameterType
       return [UNKNOWN_TYPE]
 
     case 'TSParenthesizedType':