We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
atom
1 parent 876fa5e commit c04b01cCopy full SHA for c04b01c
.changeset/polite-terms-dress.md
@@ -0,0 +1,5 @@
1
+---
2
+'atomsphere': patch
3
4
+
5
+Improve types in `atom` function
src/atom.ts
@@ -11,7 +11,9 @@ type DeriveFn<T> = (get: <P>(atom: ReadableAtom<P>) => P) => T;
11
12
export function atom<T>(initialValue: DeriveFn<T>): ReadableAtom<T>;
13
export function atom<T>(initialValue: T): WritableAtom<T>;
14
-export function atom<T>(initialValue: T | DeriveFn<T>) {
+export function atom<T>(
15
+ initialValue: T | DeriveFn<T>,
16
+): WritableAtom<T> | ReadableAtom<T> {
17
return typeof initialValue === 'function'
18
? createDerivedAtom(initialValue as DeriveFn<T>)
19
: createAtom(initialValue);
0 commit comments