Skip to content

Commit

Permalink
fix: use shallowReadonly instead deep readonly
Browse files Browse the repository at this point in the history
This fix an unwanted behavior when using typescript that the returned
type don't match assign to type passed by generic or infered from
fetcher
  • Loading branch information
edumudu committed Nov 21, 2022
1 parent 0e8a58d commit 712a498
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/composables/swr/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, readonly, watch, toRefs, unref, customRef, onUnmounted } from 'vue';
import { computed, shallowReadonly, watch, toRefs, unref, customRef, onUnmounted } from 'vue';
import {
createUnrefFn,
toReactive,
Expand Down Expand Up @@ -202,9 +202,9 @@ export const useSWR = <Data = any, Error = any>(
}

return {
data: readonly(data),
error: readonly(error),
isValidating: readonly(isValidating),
data: shallowReadonly(data),
error: shallowReadonly(error),
isValidating: shallowReadonly(isValidating),
mutate: (...params: OmitFirstArrayIndex<Parameters<typeof mutate>>) =>
mutate(unref(_key), ...params),
};
Expand Down

0 comments on commit 712a498

Please sign in to comment.