Skip to content

Commit

Permalink
Clarify types of select/multiSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
inlined committed Feb 7, 2024
1 parent 5f5554d commit a7838f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/params/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ export class CompareExpression<
type ParamValueType = "string" | "list" | "boolean" | "int" | "float" | "secret";

/** Create a select input from a series of values. */
export function select<T>(options: T[]): SelectInput;
export function select<T>(options: T[]): SelectInput<T>;

/** Create a select input from a map of labels to vaues. */
export function select<T>(optionsWithLabels: Record<string, T>): SelectInput;
export function select<T>(optionsWithLabels: Record<string, T>): SelectInput<T>;

/** Create a select input from a series of values or a map of labels to values */
export function select<T>(options: T[] | Record<string, T>): SelectInput {
export function select<T>(options: T[] | Record<string, T>): SelectInput<T> {
let wireOpts: SelectOptions<T>[];
if (Array.isArray(options)) {
wireOpts = options.map((opt) => ({ value: opt }));
Expand Down Expand Up @@ -216,7 +216,7 @@ export function multiSelect(options: string[] | Record<string, string>): MultiSe
type ParamInput<T> =
| TextInput<T>
| SelectInput<T>
| (T extends unknown[] ? MultiSelectInput : never)
| (T extends string[] ? MultiSelectInput : never)
| (T extends string ? ResourceInput : never);

/**
Expand Down

0 comments on commit a7838f5

Please sign in to comment.