Skip to content

Commit 5c7bc89

Browse files
committed
type fixes
1 parent ee20297 commit 5c7bc89

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/leva/src/types/public.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,14 @@ export type SelectOption<T = unknown> = { value: T; label?: string }
108108

109109
type SelectInput = { options: any[] | Record<string, any> | SelectOption[]; value?: any }
110110

111-
type SelectWithValueInput<T, K> = { options: T[] | Record<string, T> | SelectOption<T>[]; value: K }
112-
type SelectWithoutValueInput<T> = { options: T[] | Record<string, T> | SelectOption<T>[] }
111+
// Union branches prevent SelectOption objects from appearing in inferred value types.
112+
// SelectOption<T>[] branch extracts T; Exclude<T, SelectOption> branch handles primitives.
113+
type SelectWithValueInput<T, K> =
114+
| { options: SelectOption<T>[]; value: K }
115+
| { options: Exclude<T, SelectOption<any>>[] | Record<string, Exclude<T, SelectOption<any>>>; value: K }
116+
type SelectWithoutValueInput<T> =
117+
| { options: SelectOption<T>[] }
118+
| { options: Exclude<T, SelectOption<any>>[] | Record<string, Exclude<T, SelectOption<any>>> }
113119

114120
type ColorRgbaInput = { r: number; g: number; b: number; a?: number }
115121
type ColorHslaInput = { h: number; s: number; l: number; a?: number }

0 commit comments

Comments
 (0)