Skip to content

Commit a9e3fa4

Browse files
authored
refactor(types): improve of type assertion (#4177)
Co-authored-by: webfansplz <>
1 parent 3a13074 commit a9e3fa4

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

packages/runtime-core/src/components/BaseTransition.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ if (__COMPAT__) {
274274

275275
// export the public type for h/tsx inference
276276
// also to avoid inline import() in generated d.ts files
277-
export const BaseTransition = BaseTransitionImpl as any as {
277+
export const BaseTransition = BaseTransitionImpl as unknown as {
278278
new (): {
279279
$props: BaseTransitionProps<any>
280280
}

packages/runtime-core/src/components/Suspense.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ export const SuspenseImpl = {
8989
}
9090

9191
// Force-casted public typing for h and TSX props inference
92-
export const Suspense = (__FEATURE_SUSPENSE__ ? SuspenseImpl : null) as any as {
92+
export const Suspense = (__FEATURE_SUSPENSE__
93+
? SuspenseImpl
94+
: null) as unknown as {
9395
__isSuspense: true
9496
new (): { $props: VNodeProps & SuspenseProps }
9597
}

packages/runtime-core/src/components/Teleport.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ const resolveTarget = <T = RendererElement>(
5252
`ideally should be outside of the entire Vue component tree.`
5353
)
5454
}
55-
return target as any
55+
return target as T
5656
}
5757
} else {
5858
if (__DEV__ && !targetSelector && !isTeleportDisabled(props)) {
5959
warn(`Invalid Teleport target: ${targetSelector}`)
6060
}
61-
return targetSelector as any
61+
return targetSelector as T
6262
}
6363
}
6464

@@ -388,7 +388,7 @@ function hydrateTeleport(
388388
}
389389

390390
// Force-casted public typing for h and TSX props inference
391-
export const Teleport = TeleportImpl as any as {
391+
export const Teleport = TeleportImpl as unknown as {
392392
__isTeleport: true
393393
new (): { $props: VNodeProps & TeleportProps }
394394
}

packages/shared/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
100100
return ((str: string) => {
101101
const hit = cache[str]
102102
return hit || (cache[str] = fn(str))
103-
}) as any
103+
}) as T
104104
}
105105

106106
const camelizeRE = /-(\w)/g

packages/template-explorer/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,5 @@ function debounce<T extends (...args: any[]) => any>(
275275
fn(...args)
276276
prevTimer = null
277277
}, delay)
278-
}) as any
278+
}) as T
279279
}

0 commit comments

Comments
 (0)