Skip to content

Commit

Permalink
fix: #4196
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Aug 9, 2024
1 parent d6e4aad commit b4c8971
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/big-humans-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wagmi/core": patch
---

Made `serialize` and `deserialize` types more permissive.
12 changes: 12 additions & 0 deletions packages/core/src/createStorage.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ test('setItem', () => {
// @ts-expect-error incorrect argument type
storage.setItem('recentConnectorId', 1n)
})

test('serialize/deserialize types', () => {
createStorage({
deserialize(value) {
return value
},
serialize(value) {
return value
},
storage: localStorage,
})
})
4 changes: 2 additions & 2 deletions packages/core/src/createStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export type BaseStorage = {
}

export type CreateStorageParameters = {
deserialize?: (<T>(value: string) => T) | undefined
deserialize?: (<type>(value: string) => type | unknown) | undefined
key?: string | undefined
serialize?: (<T>(value: T) => string) | undefined
serialize?: (<type>(value: type | any) => string) | undefined
storage?: Compute<BaseStorage> | undefined
}

Expand Down

0 comments on commit b4c8971

Please sign in to comment.