Why CSF Args Type is Partial type ?
See original GitHub issueDescribe the bug
I use storybook for react on TypeScript and create stories using CSF format.
like this:
Component
type Props = {
title: string;
descriptions: string[];
};
export default function App(props: Props) {
...
Story
const meta: Meta = {
title: "App",
component: App
};
export default meta;
const Template: Story<React.ComponentProps<typeof App>> = (args) => (
<App {...args} />
);
export const NgPattern = Template.bind({});
// expect type error
NgPattern.args = {
title: "Title"
// descriptions: [],
};
I do not know why component arg type is not strict. If I make a mistake in using it, please let me know.
To Reproduce
https://codesandbox.io/s/sharp-raman-2rbk6?file=/src/App.stories.tsx
Expected behavior
The props types error is showed like this:
Property 'descriptions' is missing in type '{ title: string; }' but required in type 'Props'.
System
Environment Info:
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
Binaries:
Node: 14.15.4 - ~/.nodebrew/current/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.11 - ~/.nodebrew/current/bin/npm
Browsers:
Chrome: 88.0.4324.96
Edge: 87.0.664.57
Firefox: 70.0.1
Safari: 14.0
npmPackages:
@storybook/react: 6.1.15 => 6.1.15
Additional context
If here type args?: Partial<Args>;
become args?: Args;
, It works as expected.
https://github.com/storybookjs/storybook/blob/next/lib/addons/src/types.ts#L171
Issue Analytics
- State:
- Created 3 years ago
- Reactions:30
- Comments:35 (19 by maintainers)
Top Results From Across the Web
Args - Storybook - JS.ORG
It is a JSON serializable object composed of string keys with matching valid value types that can be passed into a component for...
Read more >Typescript support in CSF3 - storybook - Stack Overflow
Default has an error on args which appears to relate to the component props (and might be a "valid" TS error by which...
Read more >Imaging of cerebrospinal fluid flow: fundamentals, techniques ...
Pulsatile CSF flow can be displayed in both type of images, thanks to PC-MRI ... to the unidirectional flow (jets), to prevent a...
Read more >FAST - FSL - FslWiki
FAST (FMRIB's Automated Segmentation Tool) segments a 3D image of the brain into different tissue types (Grey Matter, White Matter, CSF, ...
Read more >Media Types - Internet Assigned Numbers Authority
Hence, the media type registry disallows parameters named "q". ... vnd.adobe.partial-upload, application/vnd.adobe.partial-upload ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Discussed another approach with @shilman and @yannbf that doesn’t use factories so that we have predictable AST for tools to statically analyze:
The helper:
The component:
The story:
I found that with
CSFType
above,args
always has to be specified in meta. Here’s a version I adjusted which allows for a missingargs
key, which just makes all of the props required on each story’sargs
.