Skip to content

Commit c04b01c

Browse files
committed
types: improve types in atom function
1 parent 876fa5e commit c04b01c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/polite-terms-dress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'atomsphere': patch
3+
---
4+
5+
Improve types in `atom` function

src/atom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ type DeriveFn<T> = (get: <P>(atom: ReadableAtom<P>) => P) => T;
1111

1212
export function atom<T>(initialValue: DeriveFn<T>): ReadableAtom<T>;
1313
export function atom<T>(initialValue: T): WritableAtom<T>;
14-
export function atom<T>(initialValue: T | DeriveFn<T>) {
14+
export function atom<T>(
15+
initialValue: T | DeriveFn<T>,
16+
): WritableAtom<T> | ReadableAtom<T> {
1517
return typeof initialValue === 'function'
1618
? createDerivedAtom(initialValue as DeriveFn<T>)
1719
: createAtom(initialValue);

0 commit comments

Comments
 (0)