From e789a4dd6a9319d3ad39379d80e1b58c68ba29f3 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 10 Sep 2021 07:46:27 +0800 Subject: [PATCH] Revert "Feature: make return state(data, error and isValidating) readonly" (#1443) * Revert "make return state(data, error and isValidating) readonly (#1431)" This reverts commit ec778e70c8e17c239f2837c14dea99ce9a429fb0. * enable diagnostics on CI --- jest.config.js | 2 +- src/types.ts | 6 +++--- test/use-swr-immutable.test.tsx | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/jest.config.js b/jest.config.js index fbe8209c4..300902b59 100644 --- a/jest.config.js +++ b/jest.config.js @@ -12,7 +12,7 @@ module.exports = { globals: { 'ts-jest': { tsconfig: 'test/tsconfig.json', - diagnostics: false, + diagnostics: process.env.CI, } }, } diff --git a/src/types.ts b/src/types.ts index 9481a36bd..206a00ae6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -148,10 +148,10 @@ export type SWRConfiguration< export type Key = ValueKey | (() => ValueKey) export interface SWRResponse { - data?: Readonly - error?: Readonly + data?: Data + error?: Error mutate: KeyedMutator - isValidating: Readonly + isValidating: boolean } export type KeyLoader = diff --git a/test/use-swr-immutable.test.tsx b/test/use-swr-immutable.test.tsx index 2f462ca44..b57aec46c 100644 --- a/test/use-swr-immutable.test.tsx +++ b/test/use-swr-immutable.test.tsx @@ -140,10 +140,7 @@ describe('useSWR - immutable', () => { }) it('should not revalidate with revalidateIfStale disabled when key changes', async () => { - const fetcher = jest.fn(v => { - console.log(v) - return v - }) + const fetcher = jest.fn(v => v) const key = createKey() const useData = (id: string) =>