From 9c4d4f06150af2e910b7ed31e3c2684315707c84 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Thu, 12 Dec 2024 12:49:32 +0100 Subject: [PATCH 1/2] Experimental Nextjs: Add docgen types to main config --- .../experimental-nextjs-vite/src/types.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/code/frameworks/experimental-nextjs-vite/src/types.ts b/code/frameworks/experimental-nextjs-vite/src/types.ts index 8de91a4430d9..588caf0919bf 100644 --- a/code/frameworks/experimental-nextjs-vite/src/types.ts +++ b/code/frameworks/experimental-nextjs-vite/src/types.ts @@ -1,10 +1,13 @@ import type { CompatibleString, StorybookConfig as StorybookConfigBase, + TypescriptOptions as TypescriptOptionsBase, } from 'storybook/internal/types'; import type { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite'; +import type docgenTypescript from '@joshwooding/vite-plugin-react-docgen-typescript'; + type FrameworkName = CompatibleString<'@storybook/experimental-nextjs-vite'>; type BuilderName = CompatibleString<'@storybook/builder-vite'>; @@ -31,10 +34,23 @@ type StorybookConfigFramework = { }; }; +type TypescriptOptions = TypescriptOptionsBase & { + /** + * Sets the type of Docgen when working with React and TypeScript + * + * @default `'react-docgen'` + */ + reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false; + /** Configures `@joshwooding/vite-plugin-react-docgen-typescript` */ + reactDocgenTypescriptOptions: Parameters[0]; +}; + /** The interface for Storybook configuration in `main.ts` files. */ export type StorybookConfig = Omit< StorybookConfigBase, - keyof StorybookConfigVite | keyof StorybookConfigFramework + keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript' > & StorybookConfigVite & - StorybookConfigFramework & {}; + StorybookConfigFramework & { + typescript?: Partial; + }; From bb323de1fc7413a0a7a318e76ba0286cc8c00b46 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Fri, 13 Dec 2024 11:21:30 +0100 Subject: [PATCH 2/2] simplify config types in experimental-nextjs-vite by reutilizing react-vite ones --- .../experimental-nextjs-vite/src/types.ts | 34 ++++--------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/code/frameworks/experimental-nextjs-vite/src/types.ts b/code/frameworks/experimental-nextjs-vite/src/types.ts index 588caf0919bf..0221787dccb6 100644 --- a/code/frameworks/experimental-nextjs-vite/src/types.ts +++ b/code/frameworks/experimental-nextjs-vite/src/types.ts @@ -1,12 +1,7 @@ -import type { - CompatibleString, - StorybookConfig as StorybookConfigBase, - TypescriptOptions as TypescriptOptionsBase, -} from 'storybook/internal/types'; +import type { CompatibleString } from 'storybook/internal/types'; -import type { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite'; - -import type docgenTypescript from '@joshwooding/vite-plugin-react-docgen-typescript'; +import type { BuilderOptions } from '@storybook/builder-vite'; +import type { StorybookConfig as StorybookConfigReactVite } from '@storybook/react-vite'; type FrameworkName = CompatibleString<'@storybook/experimental-nextjs-vite'>; type BuilderName = CompatibleString<'@storybook/builder-vite'>; @@ -24,7 +19,7 @@ type StorybookConfigFramework = { name: FrameworkName; options: FrameworkOptions; }; - core?: StorybookConfigBase['core'] & { + core?: StorybookConfigReactVite['core'] & { builder?: | BuilderName | { @@ -34,23 +29,6 @@ type StorybookConfigFramework = { }; }; -type TypescriptOptions = TypescriptOptionsBase & { - /** - * Sets the type of Docgen when working with React and TypeScript - * - * @default `'react-docgen'` - */ - reactDocgen: 'react-docgen-typescript' | 'react-docgen' | false; - /** Configures `@joshwooding/vite-plugin-react-docgen-typescript` */ - reactDocgenTypescriptOptions: Parameters[0]; -}; - /** The interface for Storybook configuration in `main.ts` files. */ -export type StorybookConfig = Omit< - StorybookConfigBase, - keyof StorybookConfigVite | keyof StorybookConfigFramework | 'typescript' -> & - StorybookConfigVite & - StorybookConfigFramework & { - typescript?: Partial; - }; +export type StorybookConfig = Omit & + StorybookConfigFramework;