Duplicate types and combineParameters

Because circular deps
This commit is contained in:
Tom Coleman 2020-04-22 23:39:20 +10:00
parent 9b91f38dba
commit 01867f9ab0
2 changed files with 20 additions and 4 deletions

View File

@ -93,9 +93,14 @@ export type ManagerProviderProps = RouterData &
children: ReactNode | ((props: Combo) => ReactNode);
};
// These types are duplicated in addons.
export type StoryId = string;
export type StoryKind = string;
export interface Args {
[key: string]: any;
}
export interface ArgType {
name?: string;
description?: string;
@ -107,6 +112,10 @@ export interface ArgTypes {
[key: string]: ArgType;
}
export interface Parameters {
[key: string]: any;
}
export type ModuleFn = (m: ModuleArgs) => Module;
interface Module {

View File

@ -1,11 +1,9 @@
import deprecate from 'util-deprecate';
import dedent from 'ts-dedent';
import { sanitize, parseKind } from '@storybook/csf';
import { StoryId, StoryKind, Parameters } from '@storybook/addons';
import { combineParameters } from '@storybook/client-api';
import { mapValues } from 'lodash';
import { mapValues, mergeWith } from 'lodash';
import { Args } from '../index';
import { StoryId, StoryKind, Args, Parameters } from '../index';
import merge from './merge';
import { Provider } from '../modules/provider';
@ -142,6 +140,15 @@ const toGroup = (name: string) => ({
id: toKey(name),
});
// This is duplicated from @storybook/client-api for the reasons mentioned in lib-addons/types.js
const combineParameters = (...parameterSets: Parameters[]) =>
mergeWith({}, ...parameterSets, (objValue: any, srcValue: any) => {
// Treat arrays as scalars:
if (Array.isArray(srcValue)) return srcValue;
return undefined;
});
export const denormalizeStoryParameters = ({
globalParameters,
kindParameters,