]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: tweaks 12876/head
authordaiwei <daiwei521@126.com>
Thu, 21 Aug 2025 01:34:15 +0000 (09:34 +0800)
committerdaiwei <daiwei521@126.com>
Thu, 21 Aug 2025 01:34:15 +0000 (09:34 +0800)
packages/compiler-sfc/src/script/resolveType.ts

index 494eb68c02172ce60c1306f4d145c93a8b8be054..d8f430700502922f69767112b975121b6d1881ac 100644 (file)
@@ -1589,38 +1589,32 @@ export function inferRuntimeType(
       case 'TSTypeReference': {
         const resolved = resolveTypeReference(ctx, node, scope)
         if (resolved) {
-          // #13240
-          // Special case for function type aliases to ensure correct runtime behavior
-          // other type aliases still fallback to unknown as before
-          if (
-            resolved.type === 'TSTypeAliasDeclaration' &&
-            resolved.typeAnnotation.type === 'TSFunctionType'
-          ) {
-            return ['Function']
-          }
+          if (resolved.type === 'TSTypeAliasDeclaration') {
+            // #13240
+            // Special case for function type aliases to ensure correct runtime behavior
+            // other type aliases still fallback to unknown as before
+            if (resolved.typeAnnotation.type === 'TSFunctionType') {
+              return ['Function']
+            }
 
-          if (!node.typeParameters) {
-            return inferRuntimeType(
-              ctx,
-              resolved,
-              resolved._ownerScope,
-              isKeyOf,
-            )
-          } else if (resolved.type === 'TSTypeAliasDeclaration') {
-            const typeParams: Record<string, Node> = Object.create(null)
-            if (resolved.typeParameters) {
-              resolved.typeParameters.params.forEach((p, i) => {
-                typeParams![p.name] = node.typeParameters!.params[i]
-              })
+            if (node.typeParameters) {
+              const typeParams: Record<string, Node> = Object.create(null)
+              if (resolved.typeParameters) {
+                resolved.typeParameters.params.forEach((p, i) => {
+                  typeParams![p.name] = node.typeParameters!.params[i]
+                })
+              }
+              return inferRuntimeType(
+                ctx,
+                resolved.typeAnnotation,
+                resolved._ownerScope,
+                isKeyOf,
+                typeParams,
+              )
             }
-            return inferRuntimeType(
-              ctx,
-              resolved.typeAnnotation,
-              resolved._ownerScope,
-              isKeyOf,
-              typeParams,
-            )
           }
+
+          return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf)
         }
         if (node.typeName.type === 'Identifier') {
           if (typeParameters && typeParameters[node.typeName.name]) {