@@ -515,6 +515,57 @@ describe('CsfFile', () => {
515
515
` ) ;
516
516
} ) ;
517
517
518
+ it ( 'typescript satisfies as' , ( ) => {
519
+ expect (
520
+ parse (
521
+ dedent `
522
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react';
523
+ type PropTypes = {};
524
+ export default { title: 'foo/bar' } satisfies Meta<PropTypes> as Meta<PropTypes>;
525
+ export const A = { name: 'AA' } satisfies StoryObj<PropTypes>;
526
+ export const B = ((args) => {}) satisfies StoryFn<PropTypes>;
527
+ ` ,
528
+ true
529
+ )
530
+ ) . toMatchInlineSnapshot ( `
531
+ meta:
532
+ title: foo/bar
533
+ stories:
534
+ - id: foo-bar--a
535
+ name: AA
536
+ parameters:
537
+ __isArgsStory: true
538
+ __id: foo-bar--a
539
+ __stats:
540
+ factory: false
541
+ play: false
542
+ render: false
543
+ loaders: false
544
+ beforeEach: false
545
+ globals: false
546
+ tags: false
547
+ storyFn: false
548
+ mount: false
549
+ moduleMock: false
550
+ - id: foo-bar--b
551
+ name: B
552
+ parameters:
553
+ __isArgsStory: true
554
+ __id: foo-bar--b
555
+ __stats:
556
+ factory: false
557
+ play: false
558
+ render: false
559
+ loaders: false
560
+ beforeEach: false
561
+ globals: false
562
+ tags: false
563
+ storyFn: false
564
+ mount: false
565
+ moduleMock: false
566
+ ` ) ;
567
+ } ) ;
568
+
518
569
it ( 'typescript meta var' , ( ) => {
519
570
expect (
520
571
parse (
@@ -605,6 +656,136 @@ describe('CsfFile', () => {
605
656
` ) ;
606
657
} ) ;
607
658
659
+ it ( 'typescript satisfies as meta' , ( ) => {
660
+ expect (
661
+ parse (
662
+ dedent `
663
+ import type { Meta, StoryFn } from '@storybook/react';
664
+ type PropTypes = {};
665
+ const meta = { title: 'foo/bar/baz' } satisfies Meta<PropTypes> as Meta<PropTypes>;
666
+ export default meta;
667
+ export const A: StoryFn<PropTypes> = () => <>A</>;
668
+ export const B: StoryFn<PropTypes> = () => <>B</>;
669
+ `
670
+ )
671
+ ) . toMatchInlineSnapshot ( `
672
+ meta:
673
+ title: foo/bar/baz
674
+ stories:
675
+ - id: foo-bar-baz--a
676
+ name: A
677
+ __stats:
678
+ factory: false
679
+ play: false
680
+ render: false
681
+ loaders: false
682
+ beforeEach: false
683
+ globals: false
684
+ tags: false
685
+ storyFn: true
686
+ mount: false
687
+ moduleMock: false
688
+ - id: foo-bar-baz--b
689
+ name: B
690
+ __stats:
691
+ factory: false
692
+ play: false
693
+ render: false
694
+ loaders: false
695
+ beforeEach: false
696
+ globals: false
697
+ tags: false
698
+ storyFn: true
699
+ mount: false
700
+ moduleMock: false
701
+ ` ) ;
702
+ } ) ;
703
+
704
+ it ( 'typescript satisfies as stories' , ( ) => {
705
+ expect (
706
+ parse (
707
+ dedent `
708
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react';
709
+ type PropTypes = {};
710
+ export default { title: 'foo/bar' } as Meta<PropTypes>;
711
+ export const A = { name: 'AA' } satisfies StoryObj<PropTypes> as StoryObj<PropTypes>;
712
+ export const B = ((args) => {}) satisfies StoryFn<PropTypes> as StoryFn<PropTypes>;
713
+ ` ,
714
+ true
715
+ )
716
+ ) . toMatchInlineSnapshot ( `
717
+ meta:
718
+ title: foo/bar
719
+ stories:
720
+ - id: foo-bar--a
721
+ name: AA
722
+ parameters:
723
+ __isArgsStory: true
724
+ __id: foo-bar--a
725
+ __stats:
726
+ factory: false
727
+ play: false
728
+ render: false
729
+ loaders: false
730
+ beforeEach: false
731
+ globals: false
732
+ tags: false
733
+ storyFn: false
734
+ mount: false
735
+ moduleMock: false
736
+ - id: foo-bar--b
737
+ name: B
738
+ parameters:
739
+ __isArgsStory: true
740
+ __id: foo-bar--b
741
+ __stats:
742
+ factory: false
743
+ play: false
744
+ render: false
745
+ loaders: false
746
+ beforeEach: false
747
+ globals: false
748
+ tags: false
749
+ storyFn: false
750
+ mount: false
751
+ moduleMock: false
752
+ ` ) ;
753
+ } ) ;
754
+
755
+ it ( 'typescript satisfies as export specifier' , ( ) => {
756
+ expect (
757
+ parse (
758
+ dedent `
759
+ import type { Meta, StoryFn } from '@storybook/react';
760
+ type PropTypes = {};
761
+ const meta = { title: 'foo/bar/baz' } satisfies Meta<PropTypes> as Meta<PropTypes>;
762
+ const story = { name: 'Story A' };
763
+ export { meta as default, story as A };
764
+ ` ,
765
+ true
766
+ )
767
+ ) . toMatchInlineSnapshot ( `
768
+ meta:
769
+ title: foo/bar/baz
770
+ stories:
771
+ - id: foo-bar-baz--a
772
+ name: A
773
+ localName: story
774
+ parameters:
775
+ __id: foo-bar-baz--a
776
+ __stats:
777
+ play: false
778
+ render: false
779
+ loaders: false
780
+ beforeEach: false
781
+ globals: false
782
+ tags: false
783
+ storyFn: false
784
+ mount: false
785
+ moduleMock: false
786
+ ` ) ;
787
+ } ) ;
788
+
608
789
it ( 'component object' , ( ) => {
609
790
expect (
610
791
parse (
@@ -1995,7 +2176,7 @@ describe('CsfFile', () => {
1995
2176
const { indexInputs } = loadCsf (
1996
2177
dedent `
1997
2178
const Component = (props) => <div>hello</div>;
1998
-
2179
+
1999
2180
export default {
2000
2181
title: 'custom foo title',
2001
2182
component: Component,
@@ -2513,7 +2694,7 @@ describe('CsfFile', () => {
2513
2694
) . toThrowErrorMatchingInlineSnapshot ( `
2514
2695
[MultipleMetaError: CSF: multiple meta objects (line 4, col 24)
2515
2696
2516
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2697
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2517
2698
` ) ;
2518
2699
} ) ;
2519
2700
@@ -2531,7 +2712,7 @@ describe('CsfFile', () => {
2531
2712
) . toThrowErrorMatchingInlineSnapshot ( `
2532
2713
[MultipleMetaError: CSF: multiple meta objects (line 3, col 25)
2533
2714
2534
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2715
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2535
2716
` ) ;
2536
2717
} ) ;
2537
2718
@@ -2549,7 +2730,7 @@ describe('CsfFile', () => {
2549
2730
) . toThrowErrorMatchingInlineSnapshot ( `
2550
2731
[MultipleMetaError: CSF: multiple meta objects
2551
2732
2552
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2733
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2553
2734
` ) ;
2554
2735
} ) ;
2555
2736
@@ -2565,7 +2746,7 @@ describe('CsfFile', () => {
2565
2746
) . toThrowErrorMatchingInlineSnapshot ( `
2566
2747
[BadMetaError: CSF: meta() factory must be imported from .storybook/preview configuration (line 1, col 0)
2567
2748
2568
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2749
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2569
2750
` ) ;
2570
2751
} ) ;
2571
2752
@@ -2582,7 +2763,7 @@ describe('CsfFile', () => {
2582
2763
) . toThrowErrorMatchingInlineSnapshot ( `
2583
2764
[BadMetaError: CSF: meta() factory must be imported from .storybook/preview configuration (line 4, col 28)
2584
2765
2585
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2766
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2586
2767
` ) ;
2587
2768
} ) ;
2588
2769
@@ -2599,7 +2780,7 @@ describe('CsfFile', () => {
2599
2780
) . toThrowErrorMatchingInlineSnapshot ( `
2600
2781
[MixedFactoryError: CSF: expected factory story (line 4, col 17)
2601
2782
2602
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2783
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2603
2784
` ) ;
2604
2785
} ) ;
2605
2786
@@ -2616,7 +2797,7 @@ describe('CsfFile', () => {
2616
2797
) . toThrowErrorMatchingInlineSnapshot ( `
2617
2798
[MixedFactoryError: CSF: expected non-factory story (line 4, col 28)
2618
2799
2619
- More info: https://storybook.js.org/docs/writing-stories#default-export ?ref=error]
2800
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export ]
2620
2801
` ) ;
2621
2802
} ) ;
2622
2803
} ) ;
0 commit comments