]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(types): improve of type assertion (#4177)
authorwebfansplz <308241863@qq.com>
Mon, 3 Oct 2022 08:37:54 +0000 (16:37 +0800)
committerGitHub <noreply@github.com>
Mon, 3 Oct 2022 08:37:54 +0000 (16:37 +0800)
Co-authored-by: webfansplz <>
packages/runtime-core/src/components/BaseTransition.ts
packages/runtime-core/src/components/Suspense.ts
packages/runtime-core/src/components/Teleport.ts
packages/shared/src/index.ts
packages/template-explorer/src/index.ts

index a671bef65600dd7b1041167a4603ffd21edc895a..5e5e216d34abb85ea2a315bae301a0de9a603b0a 100644 (file)
@@ -274,7 +274,7 @@ if (__COMPAT__) {
 
 // export the public type for h/tsx inference
 // also to avoid inline import() in generated d.ts files
-export const BaseTransition = BaseTransitionImpl as any as {
+export const BaseTransition = BaseTransitionImpl as unknown as {
   new (): {
     $props: BaseTransitionProps<any>
   }
index 8408cab388d62bcd11f5ce0f20b6884fa30fb4bb..baf570886266adaf574897483cf27d4c64be3c73 100644 (file)
@@ -89,7 +89,9 @@ export const SuspenseImpl = {
 }
 
 // Force-casted public typing for h and TSX props inference
-export const Suspense = (__FEATURE_SUSPENSE__ ? SuspenseImpl : null) as any as {
+export const Suspense = (__FEATURE_SUSPENSE__
+  ? SuspenseImpl
+  : null) as unknown as {
   __isSuspense: true
   new (): { $props: VNodeProps & SuspenseProps }
 }
index 06b69aff4ec911e2db330b73de20eaa2c9e60be1..e519aa2bb3a3344d24a0129805cfd1048eaaadea 100644 (file)
@@ -52,13 +52,13 @@ const resolveTarget = <T = RendererElement>(
               `ideally should be outside of the entire Vue component tree.`
           )
       }
-      return target as any
+      return target as T
     }
   } else {
     if (__DEV__ && !targetSelector && !isTeleportDisabled(props)) {
       warn(`Invalid Teleport target: ${targetSelector}`)
     }
-    return targetSelector as any
+    return targetSelector as T
   }
 }
 
@@ -388,7 +388,7 @@ function hydrateTeleport(
 }
 
 // Force-casted public typing for h and TSX props inference
-export const Teleport = TeleportImpl as any as {
+export const Teleport = TeleportImpl as unknown as {
   __isTeleport: true
   new (): { $props: VNodeProps & TeleportProps }
 }
index c1b0773292cb2b64067ee109edb2345280c5cdee..8e3020f9e3741f6dac2f9856ce734e0eb30f5ed8 100644 (file)
@@ -100,7 +100,7 @@ const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
   return ((str: string) => {
     const hit = cache[str]
     return hit || (cache[str] = fn(str))
-  }) as any
+  }) as T
 }
 
 const camelizeRE = /-(\w)/g
index d676c717373c14bd580795be5e25e6bec8dc5d30..3cf9c6b52cf2115e74a2c0bf16203421512b17b6 100644 (file)
@@ -275,5 +275,5 @@ function debounce<T extends (...args: any[]) => any>(
       fn(...args)
       prevTimer = null
     }, delay)
-  }) as any
+  }) as T
 }