select knob options object keys are strings or numbers only

* select knob uses the keys of the "options" object as the selected values, and doesn't support arbitrary types as values. 
* It only supports arbitrary types for the select->option->child. These are the values in options object. 
* The value of the select knob or the selected option however, is still either a string or number. Also, since typescript object key signature can only be either "string" or "number" (but not string | number) we need to specify both types explicitly. 
options : { [s: string | number]: T } does not work.
This commit is contained in:
Prannay Budhraja
2017-08-09 18:39:58 -07:00
committed by GitHub
parent 3b31f6b181
commit 22f17cf61d
+4 -2
View File
@@ -36,8 +36,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 function select<T>(name: string, options: { [s: string]: T }, value: string): string;
export function select<T>(name: string, options: { [s: number]: T }, value: number): number;
type SelectValue = string | number;
export function select<T extends SelectValue>(name: string, options: T[], value: T): T;
export function date(name: string, value?: Date): Date;