diff --git a/.changeset/empty-cycles-lay.md b/.changeset/empty-cycles-lay.md new file mode 100644 index 0000000000..323bf42fa3 --- /dev/null +++ b/.changeset/empty-cycles-lay.md @@ -0,0 +1,5 @@ +--- +"@vue-storefront/sdk": patch +--- + +- **[FIX]** Fixed type inference for function-based configurations when using the [extend](https://docs.alokai.com/sdk/advanced/extending-module#extend) method. Now the `methods` object is correctly typed. diff --git a/packages/sdk/src/modules/buildModule.ts b/packages/sdk/src/modules/buildModule.ts index 5adaa95ab5..0e8458a0a1 100644 --- a/packages/sdk/src/modules/buildModule.ts +++ b/packages/sdk/src/modules/buildModule.ts @@ -74,7 +74,7 @@ function buildModule< const resolvedExtension = typeof extension === "function" - ? extension(extensionOptions, { + ? extension(extensionOptions ?? ({} as ExtensionOptions), { methods: resolvedModule.connector, context: resolvedModule?.context ?? {}, }) diff --git a/packages/sdk/src/types/index.ts b/packages/sdk/src/types/index.ts index 5cbad89df2..f00141bbab 100644 --- a/packages/sdk/src/types/index.ts +++ b/packages/sdk/src/types/index.ts @@ -279,10 +279,10 @@ export type ExtensionInitializer< InitializedExtension extends Extension, Options extends ModuleOptions > = ( - options?: Options, - parent?: { + options: Options, + parent: { methods: ExtendedModule["connector"]; - context?: ExtendedModule["context"]; + context: ExtendedModule["context"]; } ) => InitializedExtension;