Skip to content

Commit

Permalink
fix: type
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-lefebvre committed Feb 1, 2024
1 parent 18f0fd0 commit 4f09493
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions package/src/utils/define-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const defineIntegration = <
name: string;
options: TOptions;
}) => ExtendedHooks;
}): [TOptions] extends [never]
? (options?: TOptions) => AstroIntegration
: (options: TOptions) => AstroIntegration => {
}): ((options?: TOptions) => AstroIntegration) => {
return (_options?: TOptions) => {
const options = defu(_options ?? {}, defaults ?? {}) as TOptions;

Expand Down
5 changes: 3 additions & 2 deletions package/tests/unit/define-integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,15 @@ describe("defineIntegration", () => {
return {} as ExtendedHooks;
});

defineIntegration({
defineIntegration<{ foo: string }>({
name,
defaults,
setup,
})();

const callArgs = setup.mock.lastCall?.[0];

expect(callArgs?.options).toEqual({});
expect(callArgs?.options).toEqual(defaults);
});

test("Setup should get called with overwritten args", () => {
Expand Down

0 comments on commit 4f09493

Please sign in to comment.