-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type of args no longer inferred in render #41
Comments
Hmm, this is an interesting problem. The issue we were trying to solve there was a problem with decorators where often times a decorator wasn't going to be specific to the args of the story it's being applied to. I'm still not totally clear on why that was a problem, perhaps that can be fixed another way. Perhaps we shouldn't have applied the same logic to the Is a workaround @IanVS to simply define the type of the render function yourself in your
|
No matter what strategy they're using, now they won't be able to add any kind of information about the Come to think of it, I believe my type-inferring strategy is a bit of a red-herring here, and that this will cause problems for anyone who needs good typing of their I tried your suggestion, but I still get errors. Here's what I tried:
But, even then, the strict definition in the library types blocks me.
|
@tmeasday did you hear any reports of problems with the typing of the
Could you explain this one a bit? I think that it's reasonable to expect that the |
Yeah, fair enough, let's do this.
I guess what I am thinking is if you have: const meta = {
args: { a: 'a' },
};
export default meta;
type Story = CSF3<typeof meta>;
export AStory : Story = {
args: { b: 'b' },
render: (args) => {}
}; Then the type of const meta = {
args: { a: 'a' },
};
export default meta;
export AStory : StoryObj = {
args: { b: 'b' },
render: (args) => {}
}; (The more "traditional" way to do it), then the type of In the current way of doing it, the type of |
Hi, I found that I am getting a lot of typescript errors in my app after updating to storybook 6.5.0-alpha.50, and I think it's due to #33 now being included. I'd like to try to understand what I should do to resolve this. cc/ @tmeasday
First, here's how I've been typing my stories. I've taken an approach based on storybookjs/storybook#13747 (comment).
Then, in my story, I use it like so:
That used to work pretty well. The type of
args
in the story was passed torender
, but now thoseargs
are justArgs
which is basically just "an object with anything in it". So<HelpTip {...args} />
fails withProperty 'children' is missing in type '{}' but required in type 'Props'.
Is there some other way I should be typing my stories? I've never been completely clear how to get good type coverage in stories, and the approach above was the closest I could get to a sane method, which will error if I do not provide all the needed props either through the default
meta
object, or the story itself.The text was updated successfully, but these errors were encountered: