diff --git a/lib/patcher/src/hooks/after.ts b/lib/patcher/src/hooks/after.ts index 5749c74..a4b253b 100644 --- a/lib/patcher/src/hooks/after.ts +++ b/lib/patcher/src/hooks/after.ts @@ -4,7 +4,12 @@ import { unproxy, } from '../_internal' import type { HookNode, PatchedFunctionProxyState } from '../_internal' -import type { AfterHook, FiniteDomain, UnknownFunction } from '../types' +import type { + AfterHook, + FiniteDomain, + UnknownFunction, + UnpatchFunction, +} from '../types' function unpatchAfter( state: PatchedFunctionProxyState, @@ -63,12 +68,12 @@ function unpatchAfter( export function after< Parent extends Record, Key extends keyof Parent, ->(parent: Parent, key: Key, hook: AfterHook): () => void +>(parent: Parent, key: Key, hook: AfterHook): UnpatchFunction export function after( parent: Record, key: FiniteDomain, hook: AfterHook, -) { +): UnpatchFunction { const target = parent[key] let state = patchedFunctionProxyStates.get(target) diff --git a/lib/patcher/src/hooks/before.ts b/lib/patcher/src/hooks/before.ts index 79b67f8..6b0a858 100644 --- a/lib/patcher/src/hooks/before.ts +++ b/lib/patcher/src/hooks/before.ts @@ -4,7 +4,12 @@ import { unproxy, } from '../_internal' import type { HookNode, PatchedFunctionProxyState } from '../_internal' -import type { BeforeHook, FiniteDomain, UnknownFunction } from '../types' +import type { + BeforeHook, + FiniteDomain, + UnknownFunction, + UnpatchFunction, +} from '../types' function unpatchBefore( state: PatchedFunctionProxyState, @@ -63,12 +68,12 @@ function unpatchBefore( export function before< Parent extends Record, Key extends keyof Parent, ->(parent: Parent, key: Key, hook: BeforeHook): () => void +>(parent: Parent, key: Key, hook: BeforeHook): UnpatchFunction export function before( parent: Record, key: FiniteDomain, hook: BeforeHook, -) { +): UnpatchFunction { const target = parent[key] let state = patchedFunctionProxyStates.get(target) diff --git a/lib/patcher/src/hooks/instead.ts b/lib/patcher/src/hooks/instead.ts index 9d01689..478bad4 100644 --- a/lib/patcher/src/hooks/instead.ts +++ b/lib/patcher/src/hooks/instead.ts @@ -15,6 +15,7 @@ import type { FiniteDomain, InsteadHook, UnknownFunction, + UnpatchFunction, } from '../types' const insteadHookProxyHandler = { @@ -110,12 +111,12 @@ function unpatchInstead( export function instead< Parent extends Record, Key extends keyof Parent, ->(parent: Parent, key: Key, hook: InsteadHook): () => void +>(parent: Parent, key: Key, hook: InsteadHook): UnpatchFunction export function instead( parent: Record, key: FiniteDomain, hook: InsteadHook, -) { +): UnpatchFunction { const target = parent[key] let state = patchedFunctionProxyStates.get(target) diff --git a/lib/patcher/src/types.ts b/lib/patcher/src/types.ts index 78f75e7..5755f1f 100644 --- a/lib/patcher/src/types.ts +++ b/lib/patcher/src/types.ts @@ -222,3 +222,5 @@ export type OverloadUnionNewableInner< ConcreteNewable > : never + +export type UnpatchFunction = () => void