Skip to content

Commit

Permalink
feat(types): enhance type for onErrorCaptured (#12735)
Browse files Browse the repository at this point in the history
  • Loading branch information
nooooooom authored Aug 18, 2022
1 parent 9eb8ea5 commit bba6b3d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/v3/apiLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const onBeforeUpdate = createLifeCycle('beforeUpdate')
export const onUpdated = createLifeCycle('updated')
export const onBeforeUnmount = createLifeCycle('beforeDestroy')
export const onUnmounted = createLifeCycle('destroyed')
export const onErrorCaptured = createLifeCycle('errorCaptured')
export const onActivated = createLifeCycle('activated')
export const onDeactivated = createLifeCycle('deactivated')
export const onServerPrefetch = createLifeCycle('serverPrefetch')
Expand All @@ -51,3 +50,19 @@ export const onRenderTracked =
createLifeCycle<(e: DebuggerEvent) => any>('renderTracked')
export const onRenderTriggered =
createLifeCycle<(e: DebuggerEvent) => any>('renderTriggered')

export type ErrorCapturedHook<TError = unknown> = (
err: TError,
instance: any,
info: string
) => boolean | void

const injectErrorCapturedHook =
createLifeCycle<ErrorCapturedHook<any>>('errorCaptured')

export function onErrorCaptured<TError = Error>(
hook: ErrorCapturedHook<TError>,
target: any = currentInstance
) {
injectErrorCapturedHook(hook, target)
}

0 comments on commit bba6b3d

Please sign in to comment.