Skip to content

Commit

Permalink
fix: type inference for the module build
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszherba committed Apr 11, 2024
1 parent 633b422 commit f721636
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ import type { Module } from '@vue-storefront/sdk';
import { connector } from './connector';
import { ModuleOptions } from './types';

/**
* @deprecated This type is deprecated and will be removed in the next major version.
* It is no longer necessary to use this type. Please, check documentation of `magentoModule`.
*/
export interface MagentoModuleType extends Module {
connector: ReturnType<typeof connector>;
}

/**
* Magento module.
*
* @example
*
* Initialization of the Magento module.
* @example Initialization of the Magento module.
*
* ```js
* import { initSDK, buildModule } from '@vue-storefront/sdk';
* import { magentoModule, MagentoModuleType } from '@vue-storefront/magento2-sdk'
*
* const sdkConfig = {
* magento:
* buildModule<MagentoModuleType>(
* buildModule(
* magentoModule,
* {
* apiUrl: 'http://localhost:8181/magento',
Expand All @@ -30,7 +32,7 @@ export interface MagentoModuleType extends Module {
* export const sdk = initSDK<typeof sdkConfig>(sdkConfig);
* ```
*/
export const magentoModule = (options: ModuleOptions): MagentoModuleType => {
export const magentoModule = (options: ModuleOptions) => {
return {
connector: connector(options),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/ModuleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export interface ModuleOptions {
/**
* The SSR API URL of the Magento instance
*/
ssrApiUrl: string;
ssrApiUrl?: string;
}

0 comments on commit f721636

Please sign in to comment.