no ts suggestion for play func. with csf next #33434
-
|
@dosu, i am not getting ts suggestions for export const Default = meta.story({
play: async ({ canvas, userEvent }) => {},
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You won't get TypeScript suggestions for
import type { Meta, StoryObj } from '@storybook/react'; // or your framework
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {
play: async ({ canvas, userEvent }) => {
// canvas and userEvent now have full TS support
},
};If you use To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
You won't get TypeScript suggestions for
canvasanduserEventin your play function unless you do two things:Add
import 'storybook/test';somewhere in your project (just once, not in every file). This enables the correct types for those parameters and unlocks intellisense for Testing Library methods in the play function context.Details & explanation
For best TypeScript inference with CSF Next, define your stories using the
StoryObj<typeof meta>pattern, like this: