Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(types): improve of type assertion #4177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function ssrTransformSuspense(
return () => {
if (node.children.length) {
const wipEntry: WIPEntry = {
slotsExp: null as any,
slotsExp: null!, // to be immediately set
wipSlots: []
}
wipMap.set(node, wipEntry)
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,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>
}
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime-core/src/components/Suspense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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 }
}
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-core/src/components/Teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -371,7 +371,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 }
}
3 changes: 1 addition & 2 deletions packages/runtime-dom/src/directives/vOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES, instance)
) {
if (instance) {
globalKeyCodes = (instance.appContext.config as any as LegacyConfig)
.keyCodes
globalKeyCodes = (instance.appContext.config as LegacyConfig).keyCodes
}
}
if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,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
Expand Down
2 changes: 1 addition & 1 deletion packages/template-explorer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,5 @@ function debounce<T extends (...args: any[]) => any>(
fn(...args)
prevTimer = null
}, delay)
}) as any
}) as T
}
2 changes: 1 addition & 1 deletion packages/vue/__tests__/e2eUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function setupPuppeteer() {

page.on('console', e => {
if (e.type() === 'error') {
const err = e.args()[0] as any
const err = e.args()[0]
console.error(
`Error from Puppeteer-loaded page:\n`,
err._remoteObject.description
Expand Down