From a216357a4520ab8820cc2421e29deb947b4bd879 Mon Sep 17 00:00:00 2001 From: Sriram Hariharan Date: Wed, 24 Apr 2024 18:13:09 -0500 Subject: [PATCH] updated use hook to now allow pulling in the entire object --- package.json | 2 +- src/storage/createStore.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7a75dcb..32f4656 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chrome-extension-toolkit", - "version": "0.0.68", + "version": "0.0.69`", "description": "A template for creating npm packages using TypeScript and VSCode", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/storage/createStore.ts b/src/storage/createStore.ts index 943e124..2c0195f 100644 --- a/src/storage/createStore.ts +++ b/src/storage/createStore.ts @@ -86,9 +86,12 @@ export type Store = { * @param key the key to get the value of or null to get the entire store * @returns a tuple containing the value of the specified key, and a function to set the value */ - use : T>( + use( key: K - ): [D, (value: D) => Promise]; + ): [ + K extends keyof T ? Serializable : T, + (value: K extends keyof T ? Serializable : Partial>) => Promise + ]; /** * A react hook that allows you to get and set the value of the specified key in the store from a functional component. @@ -100,7 +103,7 @@ export type Store = { defaultValue: K extends keyof T ? Serializable : T ): [ K extends keyof T ? Serializable : T, - (value: K extends keyof T ? Serializable : T) => Promise + (value: K extends keyof T ? Serializable : Partial>) => Promise ]; /**