diff --git a/src/vanilla/atom.ts b/src/vanilla/atom.ts index b2cfcba268c..1a314011a59 100644 --- a/src/vanilla/atom.ts +++ b/src/vanilla/atom.ts @@ -81,19 +81,23 @@ export function atom( write: Write, ): WritableAtom & WithInitialValue +// primitive atom without default value +export function atom(): PrimitiveAtom & + WithInitialValue + // primitive atom export function atom( initialValue: Value, ): PrimitiveAtom & WithInitialValue export function atom( - read: Value | Read>, + read?: Value | Read>, write?: Write, ) { const key = `atom${++keyCount}` const config = { toString: () => key, - } as WritableAtom & { init?: Value } + } as WritableAtom & WithInitialValue if (typeof read === 'function') { config.read = read as Read> } else {