diff --git a/.changeset/polite-terms-dress.md b/.changeset/polite-terms-dress.md new file mode 100644 index 0000000..de0690f --- /dev/null +++ b/.changeset/polite-terms-dress.md @@ -0,0 +1,5 @@ +--- +'atomsphere': patch +--- + +Improve types in `atom` function diff --git a/src/atom.ts b/src/atom.ts index 631c9e3..6fe4a94 100644 --- a/src/atom.ts +++ b/src/atom.ts @@ -11,7 +11,9 @@ type DeriveFn = (get:

(atom: ReadableAtom

) => P) => T; export function atom(initialValue: DeriveFn): ReadableAtom; export function atom(initialValue: T): WritableAtom; -export function atom(initialValue: T | DeriveFn) { +export function atom( + initialValue: T | DeriveFn, +): WritableAtom | ReadableAtom { return typeof initialValue === 'function' ? createDerivedAtom(initialValue as DeriveFn) : createAtom(initialValue);