From e2e2a034d60e575a43f820529b670b48f929ae6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=90=E7=8B=B8?= <134658521+Huliiiiii@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:33:37 +0800 Subject: [PATCH] Fix setter type compatibility with kobalte select and add tests (#2318) * fix kobalte select type error and add test * format * better naming * add more tests * format * add changeset --------- Co-authored-by: Ryan Carniato --- .changeset/shaggy-walls-count.md | 5 ++++ packages/solid/src/reactive/signal.ts | 8 +++--- packages/solid/test/signals.type-tests.ts | 35 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .changeset/shaggy-walls-count.md diff --git a/.changeset/shaggy-walls-count.md b/.changeset/shaggy-walls-count.md new file mode 100644 index 000000000..20f1496e6 --- /dev/null +++ b/.changeset/shaggy-walls-count.md @@ -0,0 +1,5 @@ +--- +"solid-js": patch +--- + +Fix setter type compatibility with kobalte select and add tests diff --git a/packages/solid/src/reactive/signal.ts b/packages/solid/src/reactive/signal.ts index 121c44ea0..c119df121 100644 --- a/packages/solid/src/reactive/signal.ts +++ b/packages/solid/src/reactive/signal.ts @@ -180,11 +180,11 @@ export type Accessor = () => T; export type Setter = { (value: Exclude | ((prev: T) => U)): U; - (...args: undefined extends T ? [] : [value: (prev: T) => U]): undefined extends T - ? undefined - : U; - (value: Exclude): U; + ( + ...args: undefined extends T ? [] : [value: Exclude | ((prev: T) => U)] + ): undefined extends T ? undefined : U; (value: (prev: T) => U): U; + (value: Exclude): U; }; export type Signal = [get: Accessor, set: Setter]; diff --git a/packages/solid/test/signals.type-tests.ts b/packages/solid/test/signals.type-tests.ts index 25272dfbf..b3ffa430d 100644 --- a/packages/solid/test/signals.type-tests.ts +++ b/packages/solid/test/signals.type-tests.ts @@ -880,6 +880,41 @@ function createInitializedSignal(init: T): Signal { return [generic, (v?) => setGeneric(v!)]; } +interface KobalteBaseSelectProps { + options: Array