From 3899d26bf19ffd79cd39f7b1756ccaea36f5cb36 Mon Sep 17 00:00:00 2001 From: David Sally Date: Tue, 10 Mar 2020 14:29:05 -0700 Subject: [PATCH] Allow text() and number() knobs to take undefined values This allows developers to pass optional props to text and number knobs in storybook. A common pattern for this is when a React component has an optional string or number prop. --- addons/knobs/src/components/types/Number.tsx | 7 ++----- addons/knobs/src/components/types/Text.tsx | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/knobs/src/components/types/Number.tsx b/addons/knobs/src/components/types/Number.tsx index 7778976f0e24..bfd0318a61b0 100644 --- a/addons/knobs/src/components/types/Number.tsx +++ b/addons/knobs/src/components/types/Number.tsx @@ -14,11 +14,8 @@ export interface NumberTypeKnobOptions { step?: number; } -export interface NumberTypeKnob - extends KnobControlConfig, - NumberTypeKnobOptions { - value: NumberTypeKnobValue; -} +export type NumberTypeKnob = KnobControlConfig & + NumberTypeKnobOptions & { value?: NumberTypeKnobValue }; interface NumberTypeProps extends KnobControlProps { knob: NumberTypeKnob; diff --git a/addons/knobs/src/components/types/Text.tsx b/addons/knobs/src/components/types/Text.tsx index f09c8b526ca9..c0525a606676 100644 --- a/addons/knobs/src/components/types/Text.tsx +++ b/addons/knobs/src/components/types/Text.tsx @@ -5,7 +5,7 @@ import { Form } from '@storybook/components'; import { KnobControlConfig, KnobControlProps } from './types'; type TextTypeKnobValue = string; -export type TextTypeKnob = KnobControlConfig; +export type TextTypeKnob = KnobControlConfig & { value?: TextTypeKnobValue }; type TextTypeProps = KnobControlProps; export default class TextType extends Component {