Skip to content

Commit

Permalink
Merge pull request #20166 from storybookjs/norbert/sb-919-sb19731-typ…
Browse files Browse the repository at this point in the history
…escriptcheckoptions-has-been

Fix: typescript.checkOptions not a valid interface
  • Loading branch information
tmeasday authored Dec 8, 2022
2 parents ee6b029 + 0694290 commit 0cb361f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion code/lib/builder-webpack5/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TypescriptOptions extends TypeScriptOptionsBase {
/**
* Configures `fork-ts-checker-webpack-plugin`
*/
checkOptions?: ForkTsCheckerWebpackPlugin['options'];
checkOptions?: ConstructorParameters<typeof ForkTsCheckerWebpackPlugin>[0];
}

export interface StorybookConfigWebpack extends Pick<StorybookConfig, 'webpack' | 'webpackFinal'> {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/cli/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const link = async ({ target, local, start }: LinkOptions) => {
`Magic stuff related to @storybook/preset-create-react-app, we need to fix peerDependencies`
);

if (!reproPackageJson.devDependencies.vite) {
if (!reproPackageJson.devDependencies?.vite) {
await exec(`yarn add -D webpack-hot-middleware`, { cwd: reproDir });
}

Expand Down
14 changes: 8 additions & 6 deletions code/lib/types/src/modules/core-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export interface StorybookConfig {
/**
* References external Storybooks
*/
refs?: CoreCommon_StorybookRefs | ((config: any, options: Options) => CoreCommon_StorybookRefs);
refs?: PresetValue<CoreCommon_StorybookRefs>;

/**
* Modify or return babel config.
Expand All @@ -364,17 +364,17 @@ export interface StorybookConfig {
*
* @deprecated use `previewAnnotations` or `/preview.js` file instead
*/
config?: (entries: Entry[], options: Options) => Entry[];
config?: PresetValue<Entry[]>;

/**
* Add additional scripts to run in the preview a la `.storybook/preview.js`
*/
previewAnnotations?: (entries: Entry[], options: Options) => Entry[];
previewAnnotations?: PresetValue<Entry[]>;

/**
* Process CSF files for the story index.
*/
storyIndexers?: (indexers: StoryIndexer[], options: Options) => StoryIndexer[];
storyIndexers?: PresetValue<StoryIndexer[]>;

/**
* Docs related features in index generation
Expand All @@ -386,11 +386,13 @@ export interface StorybookConfig {
* The previewHead and previewBody functions accept a string,
* which is the existing head/body, and return a modified string.
*/
previewHead?: (head: string, options: Options) => string;
previewHead?: PresetValue<string>;

previewBody?: (body: string, options: Options) => string;
previewBody?: PresetValue<string>;
}

export type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);

export type PresetProperty<K, TStorybookConfig = StorybookConfig> =
| TStorybookConfig[K extends keyof TStorybookConfig ? K : never]
| PresetPropertyFn<K, TStorybookConfig>;
Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function addEsbuildLoaderToStories(mainConfig: ConfigFile) {
(config) => ({
...config,
module: {
...config.modules,
...config.module,
rules: [
// Ensure esbuild-loader applies to all files in ./template-stories
{
Expand Down

0 comments on commit 0cb361f

Please sign in to comment.