Merge pull request #19651 from storybookjs/kasper/fix-storyobj-type

CSF: Fix `StoryObj<typeof Cmp>` to work the same as old ComponentStoryObj
This commit is contained in:
Michael Shilman 2022-10-27 23:40:40 +08:00 committed by GitHub
commit c3d86a2abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 12 deletions

View File

@ -79,7 +79,7 @@ describe('Args can be provided in multiple ways', () => {
});
test('Component can be used as generic parameter for StoryObj', () => {
type Expected = ReactStory<ButtonProps, ButtonProps>;
type Expected = ReactStory<ButtonProps, Partial<ButtonProps>>;
expectTypeOf<StoryObj<typeof Button>>().toEqualTypeOf<Expected>();
});
});

View File

@ -53,11 +53,7 @@ export type StoryObj<TMetaOrCmpOrArgs = Args> = TMetaOrCmpOrArgs extends {
>
: never
: TMetaOrCmpOrArgs extends ComponentType<any>
? StoryAnnotations<
ReactFramework,
ComponentProps<TMetaOrCmpOrArgs>,
ComponentProps<TMetaOrCmpOrArgs>
>
? StoryAnnotations<ReactFramework, ComponentProps<TMetaOrCmpOrArgs>>
: StoryAnnotations<ReactFramework, TMetaOrCmpOrArgs>;
type ActionArgs<RArgs> = {

View File

@ -141,7 +141,7 @@ describe('StoryObj', () => {
SvelteStory<
Button,
{ disabled: boolean; label: string },
{ disabled: boolean; label: string }
{ disabled?: boolean; label?: string }
>
>();
});

View File

@ -49,11 +49,7 @@ export type StoryObj<MetaOrCmpOrArgs = Args> = MetaOrCmpOrArgs extends {
>
: never
: MetaOrCmpOrArgs extends SvelteComponentTyped
? StoryAnnotations<
SvelteFramework<MetaOrCmpOrArgs>,
ComponentProps<MetaOrCmpOrArgs>,
ComponentProps<MetaOrCmpOrArgs>
>
? StoryAnnotations<SvelteFramework<MetaOrCmpOrArgs>, ComponentProps<MetaOrCmpOrArgs>>
: StoryAnnotations<SvelteFramework, MetaOrCmpOrArgs>;
export type DecoratorFn<TArgs = Args> = DecoratorFunction<SvelteFramework, TArgs>;