Skip to content

Commit

Permalink
fix: function-based configuration when using extend in the sdk (#7331)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszherba authored Nov 26, 2024
1 parent 8fd8426 commit 7a7e950
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-cycles-lay.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/sdk/src/modules/buildModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function buildModule<

const resolvedExtension =
typeof extension === "function"
? extension(extensionOptions, {
? extension(extensionOptions ?? ({} as ExtensionOptions), {
methods: resolvedModule.connector,
context: resolvedModule?.context ?? {},
})
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ export type ExtensionInitializer<
InitializedExtension extends Extension<ExtendedModule>,
Options extends ModuleOptions
> = (
options?: Options,
parent?: {
options: Options,
parent: {
methods: ExtendedModule["connector"];
context?: ExtendedModule["context"];
context: ExtendedModule["context"];
}
) => InitializedExtension;

Expand Down

0 comments on commit 7a7e950

Please sign in to comment.