UNPKG

920 BTypeScriptView Raw
1export declare type NonPromise<T> = T extends Promise<unknown> ? never : T;
2export declare type NonFunction<T> = T extends Function ? never : T;
3export declare type SetStateAction<Value> = NonFunction<Value> | ((prev: Value) => NonFunction<Value>);
4export declare type Getter = <Value>(atom: Atom<Value>) => Value;
5export declare type Setter = <Value, Update>(atom: WritableAtom<Value, Update>, update: Update) => void;
6export declare type Atom<Value> = {
7 key: string | number;
8 init?: Value;
9 read: (get: Getter) => Value | Promise<Value>;
10};
11export declare type WritableAtom<Value, Update> = Atom<Value> & {
12 write: (get: Getter, set: Setter, update: Update) => void | Promise<void>;
13};
14export declare type PrimitiveAtom<Value> = WritableAtom<Value, SetStateAction<Value>>;
15export declare type AnyAtom = Atom<unknown>;
16export declare type AnyWritableAtom = WritableAtom<unknown, unknown>;