Skip to content

Conversation

@seriouslag
Copy link

@seriouslag seriouslag commented Feb 20, 2025

This is done to support typescript declaration merging.

I have code where I augment the storybook parameters,
This causes an error in the storybook when registering the mswLoader to the storybook loaders, which uses the MSW parameters, as they now do not match.

Changing from type to an interface allows consumers to augment the types.

The consumer could augment the storybook parameters type and the mswParamters type to match.

Example to augment the interfaces in consumer code after the PR's changes:

import { mswLoader } from 'msw-storybook-addon';
...

// modifying storybook's params
declare module '@storybook/react' {
  interface Parameters {
    router?: RouterParameters;
  }
}
// modifying addon's params
declare module 'msw-storybook-addon' {
  interface MswParameters {
    router?: RouterParameters;
  }
}

// register the loaders;
// without this PR and only augmenting the storybook Parameters there would be a type error here
const loaders: StorybookLoader[] = [mswLoader];

const preview: Preview = {
  parameters,
  decorators,
  loaders,
};

export default preview;

…decorator.ts

This is done to support typescript declaration merging.

There is code where we augment the parameters in react,
this causes an error in storybook when using the MSW parameters as they do not match

Changing from type to an interface allows the consumer to augment the types.
@vercel
Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
msw-storybook-addon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 11:16pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant