diff --git a/types/storybook__addon-knobs/index.d.ts b/types/storybook__addon-knobs/index.d.ts index 7e96278069..a03c3e5f79 100644 --- a/types/storybook__addon-knobs/index.d.ts +++ b/types/storybook__addon-knobs/index.d.ts @@ -1,10 +1,11 @@ -// Type definitions for @storybook/addon-knobs 3.4 +// Type definitions for @storybook/addon-knobs 4.0 // Project: https://github.com/storybooks/storybook // Definitions by: Joscha Feth // Martynas Kadisa // A.MacLeay +// Michael Loughry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 +// TypeScript Version: 3.0 import * as React from 'react'; import { RenderFunction } from '@storybook/react'; @@ -50,13 +51,11 @@ export function object(name: string, value: T, groupId?: string): T; export function radios(name: string, options: { [s: string]: T }, value?: T, groupId?: string): string; export type SelectValue = string | number; -export function select(name: string, options: { [s: string]: string }, value: T, groupId?: string): T; -export function select(name: string, options: { [s: number]: string }, value: T, groupId?: string): T; +export function select(name: string, options: { [s: string]: T }, value: T | ReadonlyArray, groupId?: string): T; +export function select(name: string, options: { [s: string]: ReadonlyArray }, value: ReadonlyArray, groupId?: string): T[]; +export function select(name: string, options: { [s: string]: T | ReadonlyArray }, value: T | ReadonlyArray, groupId?: string): T | T[]; export function select(name: string, options: ReadonlyArray, value: T, groupId?: string): T; -export function selectV2(name: string, options: { [s: string]: T | T[] }, value: T | T[], groupId?: string): T; -export function selectV2(name: string, options: T[], value: T, groupId?: string): T; - export function date(name: string, value?: Date, groupId?: string): Date; export function array(name: string, value: ReadonlyArray, separator?: string, groupId?: string): T[]; diff --git a/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx b/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx index 6f2a50c67c..c0c7f325ed 100644 --- a/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx +++ b/types/storybook__addon-knobs/storybook__addon-knobs-tests.tsx @@ -14,7 +14,6 @@ import { array, button, knob, - selectV2, radios, } from '@storybook/addon-knobs'; @@ -38,9 +37,9 @@ stories.add('with all knobs', () => { const comfortTemp = number('Comfort Temp', 72, { range: true, min: 60, max: 90, step: 1 }); const radioStation = radios('Favorite Radio Station', { 1100: "1100", 2200: "2200", 3300: "3300" }); const textDecoration = select('Decoration', { - none: 'None', - underline: 'Underline', - 'line-through': 'Line-Through' + None: 'none', + Underline: 'underline', + 'Line-through': 'line-through' }, 'none'); const customStyle = object('Style', { @@ -52,15 +51,12 @@ stories.add('with all knobs', () => { type X = 'a' | 'b'; - const genericSelect: X = select('Some generic select', { a: 'type a', b: 'type b' }, 'b'); - const enumSelectOptions: { [s: number]: string } = {}; enumSelectOptions[SomeEnum.Type1] = "Type 1"; enumSelectOptions[SomeEnum.Type2] = "Type 2"; - const genericSelect2: SomeEnum = select('Some generic select', enumSelectOptions, SomeEnum.Type1); - const genericSelectV2: X = selectV2('Some generic select', { 'type a': 'a', 'type b': 'b' }, 'b'); - const genericSelectV2Enum: SomeEnum = selectV2('Some generic select v2', { 'type a': SomeEnum.Type1, 'type b': SomeEnum.Type2 }, SomeEnum.Type2); + const genericSelectV2: X = select('Some generic select', { 'type a': 'a', 'type b': 'b' }, 'b'); + const genericSelectV2Enum: SomeEnum = select('Some generic select v2', { 'type a': SomeEnum.Type1, 'type b': SomeEnum.Type2 }, SomeEnum.Type2); const genericArray: string[] = array('Some generic array', ['red', 'green', 'blue']);