Skip to content

Commit

Permalink
fix: do not loose default hooks params type
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Feb 6, 2024
1 parent cbadbc3 commit 2d939d7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions package/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Plugin<
THook extends keyof Hooks,
TImplementation extends (
params: HookParameters<THook>,
integrationOptions: { name: string }
integrationOptions: { name: string },
) => (...args: Array<any>) => any,
> = {
name: TName;
Expand Down Expand Up @@ -71,11 +71,11 @@ export type AddedParam<
>
>;

type AddParam<Func, Param = Record<never, never>> = Func extends (
params: infer Params,
) => infer ReturnType
? (params: Params & Param) => ReturnType
: never;
type AddParam<Func, Param = never> = [Param] extends [never]
? Func
: Func extends (params: infer Params) => infer ReturnType
? (params: Params & Param) => ReturnType
: never;

export interface ExtendedHooks<TPlugins extends Array<AnyPlugin>> {
"astro:config:setup"?: AddParam<
Expand Down

0 comments on commit 2d939d7

Please sign in to comment.