#36312·storybook

[Documentation]: Explain `MSW` `StoryContext` type augmentation

Author: oleksandr-danylchenkoCreated Sep 14, 2026Updated Sep 14, 2026

Describe the problem

The Mocking network requests guide demonstrates using msw in a story's beforeEach hook:

beforeEach({ msw }) {
  msw.use(/* handlers */)
}

With TypeScript, msw is not available on StoryContext unless consumers load the addon's separate msw-storybook-addon/types entry. Importing addonMsw from msw-storybook-addon does not load this module augmentation, so tsc reports that msw does not exist on the beforeEach context.

Please document the required augmentation near the first example that uses msw, for example:

/// <reference types="msw-storybook-addon/types" />

or a type-only import of msw-storybook-addon/types.

Additional context

The addon exposes StoryContext.msw through its separate msw-storybook-addon/types export. Projects that do not explicitly include that export in tsconfig.json or a declaration file encounter the type error even when the addon is configured correctly at runtime.