Skip to content

Commit

Permalink
fix(types): withStorageValidator (#2418)
Browse files Browse the repository at this point in the history
* fix(types): withStorageValidator

* fix test
  • Loading branch information
dai-shi authored Feb 28, 2024
1 parent f8731b0 commit a1a779e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vanilla/utils/atomWithStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export interface SyncStringStorage {
export function withStorageValidator<Value>(
validator: (value: unknown) => value is Value,
): {
(storage: AsyncStorage<any>): AsyncStorage<Value>
(storage: SyncStorage<any>): SyncStorage<Value>
(storage: AsyncStorage<unknown>): AsyncStorage<Value>
(storage: SyncStorage<unknown>): SyncStorage<Value>
}

export function withStorageValidator<Value>(
Expand Down
4 changes: 2 additions & 2 deletions tests/react/vanilla-utils/atomWithStorage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ describe('atomWithStorage (with browser storage)', () => {
if (!get(isLoggedAtom)) return false
return get(isDevModeStorageAtom)
},
(get, set, value: boolean) => {
(_get, set, value: boolean) => {
set(isDevModeStorageAtom, value)
},
)
Expand Down Expand Up @@ -596,7 +596,7 @@ describe('atomWithStorage (with non-browser storage)', () => {

describe('withStorageValidator', () => {
it('should use withStorageValidator with isNumber', () => {
const storage = createJSONStorage<number>()
const storage = createJSONStorage()
const isNumber = (v: unknown): v is number => typeof v === 'number'
atomWithStorage('my-number', 0, withStorageValidator(isNumber)(storage))
})
Expand Down

0 comments on commit a1a779e

Please sign in to comment.