diff --git a/typescript/index.d.ts b/typescript/index.d.ts index 6434db13d..9b6e42a3c 100644 --- a/typescript/index.d.ts +++ b/typescript/index.d.ts @@ -55,6 +55,7 @@ export class Snapshot { getInfo_UNSTABLE(recoilValue: RecoilValue): AtomInfo; map(cb: (mutableSnapshot: MutableSnapshot) => void): Snapshot; asyncMap(cb: (mutableSnapshot: MutableSnapshot) => Promise): Promise; + retain(): () => void; } export class MutableSnapshot extends Snapshot { diff --git a/typescript/tests.ts b/typescript/tests.ts index ab3367c44..fb14b46f2 100644 --- a/typescript/tests.ts +++ b/typescript/tests.ts @@ -214,6 +214,9 @@ useRecoilCallback(({ snapshot, set, reset, gotoSnapshot }) => async () => { set(myAtom, 5); set(myAtom, 'hello'); // $ExpectError reset(myAtom); + + const release = snapshot.retain(); + release(); }); /**