Replies: 3 comments 6 replies
-
@tmeasday @yannbf do we need to add this to |
Beta Was this translation helpful? Give feedback.
-
@cgatian I am not quite following here, it is definitely possible we messed the types up so don't get me wrong! But I not 100% clear on what is going wrong here. In your first example, Which isn't exactly the same thing as In your second example, the issue seems quite simply that you are applying a decorator to a story with a defined We were trying not to make breaking changes here so if we have we should probably ease the types. |
Beta Was this translation helpful? Give feedback.
-
I have run into the same issue on my project, where I've created a decorator generator function, that creates a decorator for wrapping a story with a react-router const getWithRouterDecorator = (
routerProps?: MemoryRouterProps
): DecoratorFn => {
const withRouter = (
Story: PartialStoryFn<JSX.Element>,
storyContext: StoryContext
): JSX.Element => (
<MemoryRouter {...routerProps}>
<Story {...storyContext} />
</MemoryRouter>
);
return withRouter;
}; Upgrading to 6.4.0+ broke my typing: https://codesandbox.io/s/sb-withrouter-decorator-9d61j?file=/src/index.tsx Following your suggestion, I'd have to introduce a generic to my const getWithRouterDecorator = <ComponentProps extends Args,>(
routerProps?: MemoryRouterProps
): DecoratorFunction<ReactFramework, ComponentProps> => {
const withRouter = (
Story: PartialStoryFn<JSX.Element>,
storyContext: StoryContext
): JSX.Element => (
<MemoryRouter {...routerProps}>
<Story {...storyContext} />
</MemoryRouter>
);
return withRouter;
}; but this still doesn't satisfy typing: https://codesandbox.io/s/sb-withrouter-decorator-forked-teblw?file=/src/index.tsx:251-640 I'm not sure how best to work around this, other than coercing the returned type, which I'd rather not do: return withRouter as DecoratorFunction<ReactFramework, ComponentProps>; |
Beta Was this translation helpful? Give feedback.
-
While migrating from 6.3.1 => 6.4.1, I'm seeing some incompatible types, which look to be caused by migrations to use
@storybook/csf
types. Or I could be totally misunderstanding how this should work...The Story type defined in
@storybook/react
contains adecorators
property defined by csf inBaseAnnotations
:This story definition expects decorator functions to be defined with a specific framework as well as args defined.
But the existing
DecoratorFn
, from@storybook/react
no longer satisfies this requirement. In order to get existing decorator functions to work, you need to modify the types used.6.3.1:
6.4.1:
Here's a simple example that replicates the problem:
Beta Was this translation helpful? Give feedback.
All reactions