diff --git a/src/types.ts b/src/types.ts index db443cc3..88c024df 100644 --- a/src/types.ts +++ b/src/types.ts @@ -91,10 +91,10 @@ export interface Storage { key: K, ops?: TransactionOptions ): Promise | null>; - getItem( + getItem>( key: string, opts?: TransactionOptions - ): Promise | null>; + ): Promise; /** @experimental */ getItems: ( diff --git a/test/storage.test-d.ts b/test/storage.test-d.ts index 010b62a4..4e7758bc 100644 --- a/test/storage.test-d.ts +++ b/test/storage.test-d.ts @@ -10,6 +10,14 @@ describe("types", () => { await storage.getItem("foo") ).toEqualTypeOf(); + expectTypeOf(await storage.getItem("foo")).toEqualTypeOf< + boolean | null + >(); + + expectTypeOf( + await storage.getItem<{ hello: string }>("foo") + ).toEqualTypeOf<{ hello: string } | null>(); + await storage.setItem("foo", "str"); await storage.set("bar", 1); await storage.removeItem("foo");