Skip to content

Commit

Permalink
Improve signal setter type for code completion of string literal unio…
Browse files Browse the repository at this point in the history
…ns. (#2297)

* fix

* fix test

* Create shy-islands-talk.md

---------

Co-authored-by: Ryan Carniato <ryansolid@gmail.com>
  • Loading branch information
Huliiiiii and ryansolid authored Sep 24, 2024
1 parent 4f8597d commit 80b0958
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-islands-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"solid-js": patch
---

Improve signal setter type for code completion of string literal unions.
4 changes: 2 additions & 2 deletions packages/solid/src/reactive/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ export function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner)
export type Accessor<T> = () => T;

export type Setter<in out T> = {
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
<U extends T>(...args: undefined extends T ? [] : [value: (prev: T) => U]): undefined extends T
? undefined
: U;
<U extends T>(value: (prev: T) => U): U;
<U extends T>(value: Exclude<U, Function>): U;
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
<U extends T>(value: (prev: T) => U): U;
};

export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
Expand Down

0 comments on commit 80b0958

Please sign in to comment.