Skip to content

Commit 293bd31

Browse files
committedMar 25, 2025
fix(scripts): preserve function overload types
1 parent 95aab54 commit 293bd31

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
 

‎packages/unhead/src/scripts/types.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ export type UseScriptResolvedInput = Omit<ScriptWithoutEvents, 'src'> & { src: s
1818

1919
type BaseScriptApi = Record<symbol | string, any>
2020

21+
type PreserveOverloads<T> = T
2122
export type AsVoidFunctions<T extends BaseScriptApi> = {
22-
[key in keyof T]:
23-
T[key] extends any[] ? T[key] :
24-
T[key] extends (...args: infer A) => any ? (...args: A) => void :
25-
T[key] extends Record<any, any> ? AsVoidFunctions<T[key]> :
26-
never
23+
[K in keyof T]: T[K] extends any[]
24+
? T[K]
25+
: T[K] extends (...args: any[]) => any
26+
? PreserveOverloads<T[K]>
27+
: T[K] extends Record<any, any>
28+
? AsVoidFunctions<T[K]>
29+
: never;
2730
}
2831

2932
export type UseScriptInput = string | UseScriptResolvedInput

0 commit comments

Comments
 (0)
Please sign in to comment.