satisfies + loaders + typeof meta leads to invalid types #27100
Unanswered
ianwremmel
asked this question in
Help
Replies: 1 comment
-
At the moment we don't support this mode yet in strict mode. For now, the workaround would be to use the less strict 6.x style of writing stories with import type { Meta, StoryObj } from '@storybook/react';
function Component(props: { summarize: Set<string>; results: string[] }) {
return <div></div>;
}
const meta = {
component: Component,
render: (args, { loaded: { results } }) => (
<Component {...args} results={results} />
),
title: 'Report Processing/Test Results Summary',
} as Meta<typeof Component>
export default meta;
type Story = StoryObj<typeof meta>;
export const TestResultsSummary: Story = {
loaders: [() => ['some', 'data']],
};
export const TestResultsSummaryWithFailures: Story = {
loaders: [() => ['some', 'data']],
};
export const Truncated: Story = {
args: {
summarize: new Set(['failure']),
},
loaders: [() => ['some', 'data']],
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Using the
satisfies
operator combined withtype Story = StoryObj<typeof meta>;
, if my stories have aloader
prop, then typescript demands every story have a completeargs
prop. If, however, I usetype Story = StoryObj<typeof MyComponent>;
, TypeScript is satisfied.If I'm reading it right, there's no way for TypeScript to know that the required prop comes from the
loader
and not fromargs
. Is there a workaround for this? I couldn't find much in the way of documentation or examples for how to usesatisfies
correcty.Additional information
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions