mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge branch 'prannayb-patch-1'
This commit is contained in:
6
types/storybook__addon-knobs/index.d.ts
vendored
6
types/storybook__addon-knobs/index.d.ts
vendored
@@ -37,8 +37,10 @@ export function color(name: string, value: string): string;
|
||||
|
||||
export function object<T>(name: string, value: T): T;
|
||||
|
||||
export function select<T>(name: string, options: { [s: string]: T }, value: string): T;
|
||||
export function select(name: string, options: string[], value: string): string;
|
||||
export type SelectValue = string | number;
|
||||
export function select<T extends string>(name: string, options: { [s: string]: string }, value: T): T;
|
||||
export function select<T extends number>(name: string, options: { [s: number]: string }, value: T): T;
|
||||
export function select<T extends SelectValue>(name: string, options: T[], value: T): T;
|
||||
|
||||
export function date(name: string, value?: Date): Date;
|
||||
|
||||
|
||||
@@ -14,6 +14,11 @@ import {
|
||||
knob,
|
||||
} from '@storybook/addon-knobs';
|
||||
|
||||
enum SomeEnum {
|
||||
Type1 = 1,
|
||||
Type2
|
||||
}
|
||||
|
||||
const stories = storiesOf('Example of Knobs', module);
|
||||
|
||||
stories.addDecorator(withKnobs);
|
||||
@@ -39,9 +44,18 @@ stories.add('with all knobs', () => {
|
||||
});
|
||||
|
||||
const genericObject: string = object<string>('Some generic object', 'value');
|
||||
|
||||
type X = 'a' | 'b';
|
||||
const genericSelect: X = select<X>('Some generic select', { a: 'a', b: 'b'}, 'b');
|
||||
|
||||
const genericSelect: X = select<X>('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<SomeEnum>('Some generic select', enumSelectOptions, SomeEnum.Type1);
|
||||
|
||||
const genericArray: string[] = array<string>('Some generic array', ['red', 'green', 'blue']);
|
||||
|
||||
const genericKnob: X = knob<X>('Some generic knob', { value: 'a', type: 'text' });
|
||||
|
||||
const style = {
|
||||
|
||||
Reference in New Issue
Block a user