mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
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:
+4
-2
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user