@khanacademy/wonder-blocks-data 10.1.0 → 10.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/data.d.ts +52 -0
  3. package/dist/components/data.js.flow +63 -0
  4. package/dist/components/gql-router.d.ts +24 -0
  5. package/dist/components/gql-router.js.flow +33 -0
  6. package/dist/components/intercept-context.d.ts +10 -0
  7. package/dist/components/intercept-context.js.flow +19 -0
  8. package/dist/components/intercept-requests.d.ts +42 -0
  9. package/dist/components/intercept-requests.js.flow +51 -0
  10. package/dist/components/track-data.d.ts +11 -0
  11. package/dist/components/track-data.js.flow +18 -0
  12. package/dist/es/index.js +184 -212
  13. package/dist/hooks/use-cached-effect.d.ts +70 -0
  14. package/dist/hooks/use-cached-effect.js.flow +85 -0
  15. package/dist/hooks/use-gql-router-context.d.ts +5 -0
  16. package/dist/hooks/use-gql-router-context.js.flow +15 -0
  17. package/dist/hooks/use-gql.d.ts +12 -0
  18. package/dist/hooks/use-gql.js.flow +29 -0
  19. package/dist/hooks/use-hydratable-effect.d.ts +102 -0
  20. package/dist/hooks/use-hydratable-effect.js.flow +125 -0
  21. package/dist/hooks/use-request-interception.d.ts +14 -0
  22. package/dist/hooks/use-request-interception.js.flow +25 -0
  23. package/dist/hooks/use-server-effect.d.ts +39 -0
  24. package/dist/hooks/use-server-effect.js.flow +51 -0
  25. package/dist/hooks/use-shared-cache.d.ts +32 -0
  26. package/dist/hooks/use-shared-cache.js.flow +43 -0
  27. package/dist/index.d.ts +24 -0
  28. package/dist/index.js +186 -217
  29. package/dist/index.js.flow +48 -2
  30. package/dist/util/data-error.d.ts +45 -0
  31. package/dist/util/data-error.js.flow +64 -0
  32. package/dist/util/get-gql-data-from-response.d.ts +4 -0
  33. package/dist/util/get-gql-data-from-response.js.flow +13 -0
  34. package/dist/util/get-gql-request-id.d.ts +5 -0
  35. package/dist/util/get-gql-request-id.js.flow +20 -0
  36. package/dist/util/gql-error.d.ts +28 -0
  37. package/dist/util/gql-error.js.flow +43 -0
  38. package/dist/util/gql-router-context.d.ts +3 -0
  39. package/dist/util/gql-router-context.js.flow +10 -0
  40. package/dist/util/gql-types.d.ts +34 -0
  41. package/dist/util/gql-types.js.flow +53 -0
  42. package/dist/util/graphql-document-node-parser.d.ts +18 -0
  43. package/dist/util/graphql-document-node-parser.js.flow +31 -0
  44. package/dist/util/graphql-types.d.ts +19 -0
  45. package/dist/util/graphql-types.js.flow +30 -0
  46. package/dist/util/hydration-cache-api.d.ts +17 -0
  47. package/dist/util/hydration-cache-api.js.flow +30 -0
  48. package/dist/util/merge-gql-context.d.ts +8 -0
  49. package/dist/util/merge-gql-context.js.flow +19 -0
  50. package/dist/util/purge-caches.d.ts +8 -0
  51. package/dist/util/purge-caches.js.flow +15 -0
  52. package/dist/util/request-api.d.ts +28 -0
  53. package/dist/util/request-api.js.flow +34 -0
  54. package/dist/util/request-fulfillment.d.ts +37 -0
  55. package/dist/util/request-fulfillment.js.flow +50 -0
  56. package/dist/util/request-tracking.d.ts +62 -0
  57. package/dist/util/request-tracking.js.flow +81 -0
  58. package/dist/util/result-from-cache-response.d.ts +5 -0
  59. package/dist/util/result-from-cache-response.js.flow +15 -0
  60. package/dist/util/scoped-in-memory-cache.d.ts +38 -0
  61. package/dist/util/scoped-in-memory-cache.js.flow +57 -0
  62. package/dist/util/serializable-in-memory-cache.d.ts +16 -0
  63. package/dist/util/serializable-in-memory-cache.js.flow +26 -0
  64. package/dist/util/ssr-cache.d.ts +51 -0
  65. package/dist/util/ssr-cache.js.flow +87 -0
  66. package/dist/util/status.d.ts +10 -0
  67. package/dist/util/status.js.flow +19 -0
  68. package/dist/util/to-gql-operation.d.ts +32 -0
  69. package/dist/util/to-gql-operation.js.flow +45 -0
  70. package/dist/util/types.d.ts +111 -0
  71. package/dist/util/types.js.flow +151 -0
  72. package/package.json +5 -6
  73. package/src/components/__tests__/{data.test.js → data.test.tsx} +42 -2
  74. package/src/components/__tests__/{gql-router.test.js → gql-router.test.tsx} +4 -5
  75. package/src/components/__tests__/{intercept-requests.test.js → intercept-requests.test.tsx} +2 -3
  76. package/src/components/__tests__/{track-data.test.js → track-data.test.tsx} +2 -3
  77. package/src/components/{data.js → data.ts} +11 -15
  78. package/src/components/{gql-router.js → gql-router.tsx} +12 -14
  79. package/src/components/{intercept-context.js → intercept-context.ts} +4 -3
  80. package/src/components/{intercept-requests.js → intercept-requests.tsx} +7 -8
  81. package/src/components/{track-data.js → track-data.tsx} +4 -5
  82. package/src/hooks/__tests__/{use-cached-effect.test.js → use-cached-effect.test.tsx} +55 -50
  83. package/src/hooks/__tests__/{use-gql-router-context.test.js → use-gql-router-context.test.tsx} +7 -7
  84. package/src/hooks/__tests__/{use-gql.test.js → use-gql.test.tsx} +20 -21
  85. package/src/hooks/__tests__/{use-hydratable-effect.test.js → use-hydratable-effect.test.ts} +42 -37
  86. package/src/hooks/__tests__/{use-request-interception.test.js → use-request-interception.test.tsx} +5 -3
  87. package/src/hooks/__tests__/{use-server-effect.test.js → use-server-effect.test.ts} +8 -2
  88. package/src/hooks/__tests__/{use-shared-cache.test.js → use-shared-cache.test.ts} +12 -12
  89. package/src/hooks/{use-cached-effect.js → use-cached-effect.ts} +27 -20
  90. package/src/hooks/{use-gql-router-context.js → use-gql-router-context.ts} +2 -3
  91. package/src/hooks/{use-gql.js → use-gql.ts} +5 -5
  92. package/src/hooks/{use-hydratable-effect.js → use-hydratable-effect.ts} +53 -58
  93. package/src/hooks/{use-request-interception.js → use-request-interception.ts} +4 -4
  94. package/src/hooks/{use-server-effect.js → use-server-effect.ts} +7 -9
  95. package/src/hooks/{use-shared-cache.js → use-shared-cache.ts} +13 -8
  96. package/src/{index.js → index.ts} +0 -1
  97. package/src/util/__tests__/{get-gql-data-from-response.test.js → get-gql-data-from-response.test.ts} +0 -1
  98. package/src/util/__tests__/{get-gql-request-id.test.js → get-gql-request-id.test.ts} +9 -11
  99. package/src/util/__tests__/{graphql-document-node-parser.test.js → graphql-document-node-parser.test.ts} +11 -12
  100. package/src/util/__tests__/{hydration-cache-api.test.js → hydration-cache-api.test.ts} +1 -2
  101. package/src/util/__tests__/{merge-gql-context.test.js → merge-gql-context.test.ts} +4 -5
  102. package/src/util/__tests__/{purge-caches.test.js → purge-caches.test.ts} +0 -1
  103. package/src/util/__tests__/{request-api.test.js → request-api.test.ts} +2 -2
  104. package/src/util/__tests__/{request-fulfillment.test.js → request-fulfillment.test.ts} +0 -1
  105. package/src/util/__tests__/{request-tracking.test.js → request-tracking.test.tsx} +13 -6
  106. package/src/util/__tests__/{result-from-cache-response.test.js → result-from-cache-response.test.ts} +2 -4
  107. package/src/util/__tests__/{scoped-in-memory-cache.test.js → scoped-in-memory-cache.test.ts} +4 -5
  108. package/src/util/__tests__/{serializable-in-memory-cache.test.js → serializable-in-memory-cache.test.ts} +7 -7
  109. package/src/util/__tests__/{ssr-cache.test.js → ssr-cache.test.ts} +3 -2
  110. package/src/util/__tests__/{to-gql-operation.test.js → to-gql-operation.test.ts} +2 -1
  111. package/src/util/{data-error.js → data-error.ts} +2 -3
  112. package/src/util/{get-gql-data-from-response.js → get-gql-data-from-response.ts} +1 -6
  113. package/src/util/{get-gql-request-id.js → get-gql-request-id.ts} +12 -16
  114. package/src/util/{gql-error.js → gql-error.ts} +2 -3
  115. package/src/util/gql-router-context.ts +6 -0
  116. package/src/util/{gql-types.js → gql-types.ts} +27 -23
  117. package/src/util/{graphql-document-node-parser.js → graphql-document-node-parser.ts} +6 -7
  118. package/src/util/graphql-types.ts +27 -0
  119. package/src/util/{hydration-cache-api.js → hydration-cache-api.ts} +4 -2
  120. package/src/util/{merge-gql-context.js → merge-gql-context.ts} +2 -2
  121. package/src/util/{purge-caches.js → purge-caches.ts} +0 -1
  122. package/src/util/{request-api.js → request-api.ts} +0 -1
  123. package/src/util/{request-fulfillment.js → request-fulfillment.ts} +13 -12
  124. package/src/util/{request-tracking.js → request-tracking.ts} +12 -13
  125. package/src/util/{result-from-cache-response.js → result-from-cache-response.ts} +3 -4
  126. package/src/util/{scoped-in-memory-cache.js → scoped-in-memory-cache.ts} +1 -2
  127. package/src/util/{serializable-in-memory-cache.js → serializable-in-memory-cache.ts} +2 -3
  128. package/src/util/{ssr-cache.js → ssr-cache.ts} +19 -18
  129. package/src/util/{status.js → status.ts} +4 -5
  130. package/src/util/{to-gql-operation.js → to-gql-operation.ts} +1 -2
  131. package/src/util/{types.js → types.ts} +39 -48
  132. package/tsconfig.json +11 -0
  133. package/tsconfig.tsbuildinfo +1 -0
  134. package/src/__docs__/_overview_.stories.mdx +0 -18
  135. package/src/__docs__/_overview_graphql.stories.mdx +0 -35
  136. package/src/__docs__/_overview_ssr_.stories.mdx +0 -185
  137. package/src/__docs__/_overview_testing_.stories.mdx +0 -123
  138. package/src/__docs__/exports.abort-inflight-requests.stories.mdx +0 -20
  139. package/src/__docs__/exports.data-error.stories.mdx +0 -23
  140. package/src/__docs__/exports.data-errors.stories.mdx +0 -23
  141. package/src/__docs__/exports.data.stories.mdx +0 -146
  142. package/src/__docs__/exports.fetch-tracked-requests.stories.mdx +0 -24
  143. package/src/__docs__/exports.get-gql-request-id.stories.mdx +0 -24
  144. package/src/__docs__/exports.gql-error.stories.mdx +0 -23
  145. package/src/__docs__/exports.gql-errors.stories.mdx +0 -20
  146. package/src/__docs__/exports.gql-router.stories.mdx +0 -29
  147. package/src/__docs__/exports.has-tracked-requests-to-be-fetched.stories.mdx +0 -20
  148. package/src/__docs__/exports.intercept-requests.stories.mdx +0 -69
  149. package/src/__docs__/exports.intialize-hydration-cache.stories.mdx +0 -29
  150. package/src/__docs__/exports.purge-caches.stories.mdx +0 -23
  151. package/src/__docs__/exports.purge-hydration-cache.stories.mdx +0 -24
  152. package/src/__docs__/exports.scoped-in-memory-cache.stories.mdx +0 -92
  153. package/src/__docs__/exports.serializable-in-memory-cache.stories.mdx +0 -112
  154. package/src/__docs__/exports.shared-cache.stories.mdx +0 -16
  155. package/src/__docs__/exports.status.stories.mdx +0 -31
  156. package/src/__docs__/exports.track-data.stories.mdx +0 -209
  157. package/src/__docs__/exports.use-cached-effect.stories.mdx +0 -44
  158. package/src/__docs__/exports.use-gql.stories.mdx +0 -41
  159. package/src/__docs__/exports.use-hydratable-effect.stories.mdx +0 -43
  160. package/src/__docs__/exports.use-server-effect.stories.mdx +0 -50
  161. package/src/__docs__/exports.use-shared-cache.stories.mdx +0 -30
  162. package/src/__docs__/exports.when-client-side.stories.mdx +0 -33
  163. package/src/__docs__/types.cached-response.stories.mdx +0 -29
  164. package/src/__docs__/types.error-options.stories.mdx +0 -21
  165. package/src/__docs__/types.fetch-policy.stories.mdx +0 -44
  166. package/src/__docs__/types.gql-context.stories.mdx +0 -20
  167. package/src/__docs__/types.gql-fetch-fn.stories.mdx +0 -24
  168. package/src/__docs__/types.gql-fetch-options.stories.mdx +0 -24
  169. package/src/__docs__/types.gql-operation-type.stories.mdx +0 -24
  170. package/src/__docs__/types.gql-operation.stories.mdx +0 -67
  171. package/src/__docs__/types.raw-scoped-cache.stories.mdx +0 -27
  172. package/src/__docs__/types.response-cache.stories.mdx +0 -33
  173. package/src/__docs__/types.result.stories.mdx +0 -39
  174. package/src/__docs__/types.scoped-cache.stories.mdx +0 -114
  175. package/src/__docs__/types.valid-cache-data.stories.mdx +0 -23
  176. package/src/util/gql-router-context.js +0 -6
  177. package/src/util/graphql-types.js +0 -30
  178. /package/src/hooks/__tests__/__snapshots__/{use-shared-cache.test.js.snap → use-shared-cache.test.ts.snap} +0 -0
  179. /package/src/util/__tests__/__snapshots__/{scoped-in-memory-cache.test.js.snap → scoped-in-memory-cache.test.ts.snap} +0 -0
  180. /package/src/util/__tests__/__snapshots__/{serializable-in-memory-cache.test.js.snap → serializable-in-memory-cache.test.ts.snap} +0 -0
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {renderHook} from "@testing-library/react-hooks";
4
3
 
@@ -30,13 +29,13 @@ describe("#useGql", () => {
30
29
  const gqlRouterContext = {
31
30
  fetch: jest.fn(),
32
31
  defaultContext: {},
33
- };
32
+ } as const;
34
33
 
35
34
  // Act
36
35
  const {
37
36
  result: {current: result},
38
37
  } = renderHook(() => useGql(), {
39
- wrapper: ({children}) => (
38
+ wrapper: ({children}: any) => (
40
39
  <GqlRouterContext.Provider value={gqlRouterContext}>
41
40
  {children}
42
41
  </GqlRouterContext.Provider>
@@ -58,18 +57,18 @@ describe("#useGql", () => {
58
57
  });
59
58
  const fetchFake = jest
60
59
  .fn()
61
- .mockResolvedValue(("FAKE_RESPONSE": any));
60
+ .mockResolvedValue("FAKE_RESPONSE" as any);
62
61
  const gqlRouterContext = {
63
62
  fetch: fetchFake,
64
63
  defaultContext: {
65
64
  a: "defaultA",
66
65
  b: "defaultB",
67
66
  },
68
- };
67
+ } as const;
69
68
  const {
70
69
  result: {current: gqlFetch},
71
70
  } = renderHook(() => useGql(), {
72
- wrapper: ({children}) => (
71
+ wrapper: ({children}: any) => (
73
72
  <GqlRouterContext.Provider value={gqlRouterContext}>
74
73
  {children}
75
74
  </GqlRouterContext.Provider>
@@ -78,14 +77,14 @@ describe("#useGql", () => {
78
77
  const gqlOp = {
79
78
  type: "query",
80
79
  id: "MyQuery",
81
- };
80
+ } as const;
82
81
  const gqlOpContext = {
83
82
  a: undefined, // This should not get included.
84
83
  b: "overrideB",
85
- };
84
+ } as const;
86
85
  const gqlOpVariables = {
87
86
  var1: "val1",
88
- };
87
+ } as const;
89
88
 
90
89
  // Act
91
90
  await gqlFetch(gqlOp, {
@@ -108,13 +107,13 @@ describe("#useGql", () => {
108
107
  some: "data",
109
108
  });
110
109
  const gqlRouterContext = {
111
- fetch: jest.fn().mockResolvedValue(("FAKE_RESPONSE": any)),
110
+ fetch: jest.fn().mockResolvedValue("FAKE_RESPONSE" as any),
112
111
  defaultContext: {},
113
- };
112
+ } as const;
114
113
  const {
115
114
  result: {current: gqlFetch},
116
115
  } = renderHook(() => useGql(), {
117
- wrapper: ({children}) => (
116
+ wrapper: ({children}: any) => (
118
117
  <GqlRouterContext.Provider value={gqlRouterContext}>
119
118
  {children}
120
119
  </GqlRouterContext.Provider>
@@ -123,7 +122,7 @@ describe("#useGql", () => {
123
122
  const gqlOp = {
124
123
  type: "query",
125
124
  id: "MyQuery",
126
- };
125
+ } as const;
127
126
 
128
127
  // Act
129
128
  await gqlFetch(gqlOp);
@@ -141,13 +140,13 @@ describe("#useGql", () => {
141
140
  "getGqlDataFromResponse",
142
141
  ).mockRejectedValue(new Error("FAKE_ERROR"));
143
142
  const gqlRouterContext = {
144
- fetch: jest.fn().mockResolvedValue(("FAKE_RESPONSE": any)),
143
+ fetch: jest.fn().mockResolvedValue("FAKE_RESPONSE" as any),
145
144
  defaultContext: {},
146
- };
145
+ } as const;
147
146
  const {
148
147
  result: {current: gqlFetch},
149
148
  } = renderHook(() => useGql(), {
150
- wrapper: ({children}) => (
149
+ wrapper: ({children}: any) => (
151
150
  <GqlRouterContext.Provider value={gqlRouterContext}>
152
151
  {children}
153
152
  </GqlRouterContext.Provider>
@@ -156,7 +155,7 @@ describe("#useGql", () => {
156
155
  const gqlOp = {
157
156
  type: "query",
158
157
  id: "MyQuery",
159
- };
158
+ } as const;
160
159
 
161
160
  // Act
162
161
  const act = gqlFetch(gqlOp);
@@ -176,13 +175,13 @@ describe("#useGql", () => {
176
175
  some: "data",
177
176
  });
178
177
  const gqlRouterContext = {
179
- fetch: jest.fn().mockResolvedValue(("FAKE_RESPONSE": any)),
178
+ fetch: jest.fn().mockResolvedValue("FAKE_RESPONSE" as any),
180
179
  defaultContext: {},
181
- };
180
+ } as const;
182
181
  const {
183
182
  result: {current: gqlFetch},
184
183
  } = renderHook(() => useGql(), {
185
- wrapper: ({children}) => (
184
+ wrapper: ({children}: any) => (
186
185
  <GqlRouterContext.Provider value={gqlRouterContext}>
187
186
  {children}
188
187
  </GqlRouterContext.Provider>
@@ -191,7 +190,7 @@ describe("#useGql", () => {
191
190
  const gqlOp = {
192
191
  type: "mutation",
193
192
  id: "MyMutation",
194
- };
193
+ } as const;
195
194
 
196
195
  // Act
197
196
  const result = await gqlFetch(gqlOp);
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {
4
3
  renderHook as clientRenderHook,
@@ -32,14 +31,14 @@ describe("#useHydratableEffect", () => {
32
31
  jest.spyOn(
33
32
  UseRequestInterception,
34
33
  "useRequestInterception",
35
- ).mockImplementation((_, handler) => handler);
34
+ ).mockImplementation((_: any, handler: any) => handler);
36
35
 
37
36
  // We need the cache to work a little so that we get our result.
38
- const cache = {};
37
+ const cache: Record<string, any> = {};
39
38
  jest.spyOn(UseSharedCache, "useSharedCache").mockImplementation(
40
- (id, _, defaultValue) => {
39
+ (id: any, _: any, defaultValue: any) => {
41
40
  const setCache = React.useCallback(
42
- (v) => (cache[id] = v),
41
+ (v: any) => (cache[id] = v),
43
42
  [id],
44
43
  );
45
44
  const currentValue =
@@ -84,7 +83,7 @@ describe("#useHydratableEffect", () => {
84
83
  ${undefined /*default*/} | ${true}
85
84
  `(
86
85
  "should call useServerEffect with the handler and hydrate=$hydrate for $clientBehavior",
87
- ({hydrate, clientBehavior}) => {
86
+ ({hydrate, clientBehavior}: any) => {
88
87
  // Arrange
89
88
  const useServerEffectSpy = jest
90
89
  .spyOn(UseServerEffect, "useServerEffect")
@@ -113,7 +112,7 @@ describe("#useHydratableEffect", () => {
113
112
  ${"foo"} | ${"foo"}
114
113
  `(
115
114
  "should call useSharedCache with id, scope=$scope, and a function to set the default",
116
- ({scope, expectedScope}) => {
115
+ ({scope, expectedScope}: any) => {
117
116
  const fakeHandler = jest.fn();
118
117
  jest.spyOn(UseServerEffect, "useServerEffect").mockReturnValue(
119
118
  Status.success({thisIs: "some data"}),
@@ -201,7 +200,7 @@ describe("#useHydratableEffect", () => {
201
200
  ${undefined /*default*/} | ${true}
202
201
  `(
203
202
  "should call useServerEffect with the handler and hydrate=$hydrate for $clientBehavior",
204
- ({hydrate, clientBehavior}) => {
203
+ ({hydrate, clientBehavior}: any) => {
205
204
  // Arrange
206
205
  const useServerEffectSpy = jest
207
206
  .spyOn(UseServerEffect, "useServerEffect")
@@ -240,7 +239,7 @@ describe("#useHydratableEffect", () => {
240
239
 
241
240
  it("should share inflight requests for the same requestId", () => {
242
241
  // Arrange
243
- const pending = new Promise((resolve, reject) => {
242
+ const pending = new Promise((resolve: any, reject: any) => {
244
243
  /*pending*/
245
244
  });
246
245
  const fakeHandler = jest.fn().mockReturnValue(pending);
@@ -259,7 +258,7 @@ describe("#useHydratableEffect", () => {
259
258
  ${Status.error(new Error("some error"))}
260
259
  `(
261
260
  "should fulfill request when server value is $serverResult and clientBehavior is ExecuteWhenNoSuccessResult",
262
- ({serverResult}) => {
261
+ ({serverResult}: any) => {
263
262
  // Arrange
264
263
  const fakeHandler = jest.fn();
265
264
  jest.spyOn(UseServerEffect, "useServerEffect").mockReturnValue(
@@ -286,7 +285,7 @@ describe("#useHydratableEffect", () => {
286
285
  ${Status.success("data")}
287
286
  `(
288
287
  "should fulfill request when server value is $serveResult and clientBehavior is AlwaysExecute",
289
- ({serverResult}) => {
288
+ ({serverResult}: any) => {
290
289
  // Arrange
291
290
  const fakeHandler = jest.fn();
292
291
  jest.spyOn(UseServerEffect, "useServerEffect").mockReturnValue(
@@ -329,7 +328,7 @@ describe("#useHydratableEffect", () => {
329
328
  ${Status.success("data")}
330
329
  `(
331
330
  "should not fulfill request when server value is $serverResult and clientBehavior is ExecuteWhenNoResult",
332
- ({serverResult}) => {
331
+ ({serverResult}: any) => {
333
332
  const fakeHandler = jest.fn();
334
333
  jest.spyOn(UseServerEffect, "useServerEffect").mockReturnValue(
335
334
  serverResult,
@@ -373,7 +372,8 @@ describe("#useHydratableEffect", () => {
373
372
 
374
373
  // Act
375
374
  const {rerender, waitForNextUpdate} = clientRenderHook(
376
- ({requestId}) => useHydratableEffect(requestId, fakeHandler),
375
+ ({requestId}: any) =>
376
+ useHydratableEffect(requestId, fakeHandler),
377
377
  {
378
378
  initialProps: {requestId: "ID"},
379
379
  },
@@ -398,7 +398,8 @@ describe("#useHydratableEffect", () => {
398
398
 
399
399
  // Act
400
400
  const {rerender, result} = clientRenderHook(
401
- ({requestId}) => useHydratableEffect(requestId, fakeHandler),
401
+ ({requestId}: any) =>
402
+ useHydratableEffect(requestId, fakeHandler),
402
403
  {
403
404
  initialProps: {requestId: "ID"},
404
405
  },
@@ -442,15 +443,14 @@ describe("#useHydratableEffect", () => {
442
443
 
443
444
  // Act
444
445
  const {rerender, result} = clientRenderHook(
445
- ({requestId}) => useHydratableEffect(requestId, fakeHandler),
446
+ ({requestId}: any) =>
447
+ useHydratableEffect(requestId, fakeHandler),
446
448
  {
447
449
  initialProps: {requestId: "ID"},
448
450
  },
449
451
  );
450
452
  rerender({requestId: "ID2"});
451
- await act((): Promise<mixed> =>
452
- Promise.all([response1, response2]),
453
- );
453
+ await act((): Promise<any> => Promise.all([response1, response2]));
454
454
 
455
455
  // Assert
456
456
  expect(result.all).not.toContainEqual(Status.success("DATA1"));
@@ -470,15 +470,14 @@ describe("#useHydratableEffect", () => {
470
470
 
471
471
  // Act
472
472
  const {rerender, result} = clientRenderHook(
473
- ({requestId}) => useHydratableEffect(requestId, fakeHandler),
473
+ ({requestId}: any) =>
474
+ useHydratableEffect(requestId, fakeHandler),
474
475
  {
475
476
  initialProps: {requestId: "ID"},
476
477
  },
477
478
  );
478
479
  rerender({requestId: "ID2"});
479
- await act((): Promise<mixed> =>
480
- Promise.all([response1, response2]),
481
- );
480
+ await act((): Promise<any> => Promise.all([response1, response2]));
482
481
 
483
482
  // Assert
484
483
  expect(result.current).toStrictEqual(Status.success("DATA2"));
@@ -510,13 +509,14 @@ describe("#useHydratableEffect", () => {
510
509
 
511
510
  // Act
512
511
  const {rerender, result} = clientRenderHook(
513
- ({skip}) => useHydratableEffect("ID", fakeHandler, {skip}),
512
+ ({skip}: any) => useHydratableEffect("ID", fakeHandler, {skip}),
514
513
  {
515
514
  initialProps: {skip: false},
516
515
  },
517
516
  );
518
517
  rerender({skip: true});
519
- await act((): Promise<mixed> => response1);
518
+
519
+ await act((): Promise<any> => response1);
520
520
 
521
521
  // Assert
522
522
  expect(result.all).not.toContainEqual(Status.success("DATA1"));
@@ -534,15 +534,13 @@ describe("#useHydratableEffect", () => {
534
534
 
535
535
  // Act
536
536
  const {rerender, result} = clientRenderHook(
537
- ({handler}) => useHydratableEffect("ID", handler),
537
+ ({handler}: any) => useHydratableEffect("ID", handler),
538
538
  {
539
539
  initialProps: {handler: fakeHandler1},
540
540
  },
541
541
  );
542
542
  rerender({handler: fakeHandler2});
543
- await act((): Promise<mixed> =>
544
- Promise.all([response1, response2]),
545
- );
543
+ await act((): Promise<any> => Promise.all([response1, response2]));
546
544
 
547
545
  // Assert
548
546
  expect(result.current).toStrictEqual(Status.success("DATA1"));
@@ -558,17 +556,19 @@ describe("#useHydratableEffect", () => {
558
556
 
559
557
  // Act
560
558
  const {rerender, result} = clientRenderHook(
561
- ({options}) => useHydratableEffect("ID", fakeHandler),
559
+ ({options}: any) => useHydratableEffect("ID", fakeHandler),
562
560
  {
563
561
  initialProps: {options: undefined},
564
562
  },
565
563
  );
566
564
  rerender({
565
+ // @ts-expect-error [FEI-5019] - TS2322 - Type '{ scope: string; }' is not assignable to type 'undefined'.
567
566
  options: {
568
567
  scope: "BLAH!",
569
568
  },
570
569
  });
571
- await act((): Promise<mixed> => response1);
570
+
571
+ await act((): Promise<any> => response1);
572
572
 
573
573
  // Assert
574
574
  expect(result.current).toStrictEqual(Status.success("DATA1"));
@@ -592,7 +592,7 @@ describe("#useHydratableEffect", () => {
592
592
  result: hookResult,
593
593
  waitForNextUpdate,
594
594
  } = clientRenderHook(
595
- ({requestId}) =>
595
+ ({requestId}: any) =>
596
596
  useHydratableEffect(requestId, fakeHandler, {
597
597
  retainResultOnChange: true,
598
598
  }),
@@ -600,7 +600,8 @@ describe("#useHydratableEffect", () => {
600
600
  initialProps: {requestId: "ID"},
601
601
  },
602
602
  );
603
- await act((): Promise<mixed> => response1);
603
+
604
+ await act((): Promise<any> => response1);
604
605
  rerender({requestId: "ID2"});
605
606
  const result = hookResult.current;
606
607
  await waitForNextUpdate();
@@ -625,7 +626,7 @@ describe("#useHydratableEffect", () => {
625
626
 
626
627
  // Act
627
628
  const {rerender, result} = clientRenderHook(
628
- ({requestId}) =>
629
+ ({requestId}: any) =>
629
630
  useHydratableEffect(requestId, fakeHandler, {
630
631
  retainResultOnChange: false,
631
632
  }),
@@ -633,7 +634,8 @@ describe("#useHydratableEffect", () => {
633
634
  initialProps: {requestId: "ID"},
634
635
  },
635
636
  );
636
- await act((): Promise<mixed> => response1);
637
+
638
+ await act((): Promise<any> => response1);
637
639
  rerender({requestId: "ID2"});
638
640
 
639
641
  // Assert
@@ -652,7 +654,8 @@ describe("#useHydratableEffect", () => {
652
654
  const {result} = clientRenderHook(() =>
653
655
  useHydratableEffect("ID", fakeHandler),
654
656
  );
655
- await act((): Promise<mixed> => response);
657
+
658
+ await act((): Promise<any> => response);
656
659
 
657
660
  // Assert
658
661
  expect(result.current).toStrictEqual(Status.success("DATA"));
@@ -672,7 +675,8 @@ describe("#useHydratableEffect", () => {
672
675
  onResultChanged: () => {},
673
676
  }),
674
677
  );
675
- await act((): Promise<mixed> => response);
678
+
679
+ await act((): Promise<any> => response);
676
680
 
677
681
  // Assert
678
682
  expect(result.current).toStrictEqual(Status.loading());
@@ -693,7 +697,8 @@ describe("#useHydratableEffect", () => {
693
697
  onResultChanged,
694
698
  }),
695
699
  );
696
- await act((): Promise<mixed> => response);
700
+
701
+ await act((): Promise<any> => response);
697
702
 
698
703
  // Assert
699
704
  expect(onResultChanged).toHaveBeenCalledWith(
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {renderHook} from "@testing-library/react-hooks";
4
3
  import InterceptRequests from "../../components/intercept-requests";
@@ -37,7 +36,7 @@ describe("#useRequestInterception", () => {
37
36
 
38
37
  // Act
39
38
  const wrapper = renderHook(
40
- ({requestId}) => useRequestInterception(requestId, handler),
39
+ ({requestId}: any) => useRequestInterception(requestId, handler),
41
40
  {initialProps: {requestId: "ID"}},
42
41
  );
43
42
  const result1 = wrapper.result.current;
@@ -53,7 +52,7 @@ describe("#useRequestInterception", () => {
53
52
 
54
53
  // Act
55
54
  const wrapper = renderHook(
56
- ({handler}) => useRequestInterception("ID", handler),
55
+ ({handler}: any) => useRequestInterception("ID", handler),
57
56
  {initialProps: {handler: jest.fn()}},
58
57
  );
59
58
  const result1 = wrapper.result.current;
@@ -81,6 +80,7 @@ describe("#useRequestInterception", () => {
81
80
  {wrapper: Wrapper, initialProps: {interceptor: interceptor1}},
82
81
  );
83
82
  const result1 = wrapper.result.current;
83
+ // @ts-expect-error [FEI-5019] - TS2345 - Argument of type '{ wrapper: ({ children, interceptor, }: any) => JSX.Element; interceptor: jest.Mock<any, any, any>; }' is not assignable to parameter of type '{ interceptor: jest.Mock<any, any, any>; }'.
84
84
  wrapper.rerender({wrapper: Wrapper, interceptor: interceptor2});
85
85
  const result2 = wrapper.result.current;
86
86
 
@@ -126,6 +126,7 @@ describe("#useRequestInterception", () => {
126
126
  interceptedHandler();
127
127
 
128
128
  // Assert
129
+ // @ts-expect-error [FEI-5019] - TS2339 - Property 'toHaveBeenCalledBefore' does not exist on type 'JestMatchers<Mock<null, [], any>>'.
129
130
  expect(interceptorNearest).toHaveBeenCalledBefore(
130
131
  interceptorFurthest,
131
132
  );
@@ -153,6 +154,7 @@ describe("#useRequestInterception", () => {
153
154
  interceptedHandler();
154
155
 
155
156
  // Assert
157
+ // @ts-expect-error [FEI-5019] - TS2339 - Property 'toHaveBeenCalledBefore' does not exist on type 'JestMatchers<Mock<null, [], any>>'.
156
158
  expect(interceptorFurthest).toHaveBeenCalledBefore(handler);
157
159
  });
158
160
 
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import {renderHook as clientRenderHook} from "@testing-library/react-hooks";
3
2
  import {renderHook as serverRenderHook} from "@testing-library/react-hooks/server";
4
3
 
@@ -33,7 +32,7 @@ describe("#useServerEffect", () => {
33
32
  jest.spyOn(
34
33
  UseRequestInterception,
35
34
  "useRequestInterception",
36
- ).mockImplementation((_, handler) => handler);
35
+ ).mockImplementation((_: any, handler: any) => handler);
37
36
  });
38
37
 
39
38
  it("should call useRequestInterception", () => {
@@ -140,6 +139,7 @@ describe("#useServerEffect", () => {
140
139
  const interceptedHandler = jest.fn();
141
140
  jest.spyOn(SsrCache.Default, "getEntry").mockReturnValueOnce({
142
141
  data: "DATA",
142
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'undefined'.
143
143
  error: null,
144
144
  });
145
145
  jest.spyOn(
@@ -165,6 +165,7 @@ describe("#useServerEffect", () => {
165
165
  const fakeHandler = jest.fn();
166
166
  jest.spyOn(SsrCache.Default, "getEntry").mockReturnValueOnce({
167
167
  data: "DATA",
168
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'undefined'.
168
169
  error: null,
169
170
  });
170
171
 
@@ -181,7 +182,9 @@ describe("#useServerEffect", () => {
181
182
  // Arrange
182
183
  const fakeHandler = jest.fn();
183
184
  jest.spyOn(SsrCache.Default, "getEntry").mockReturnValueOnce({
185
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'ValidCacheData'.
184
186
  data: null,
187
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'string' is not assignable to type 'undefined'.
185
188
  error: "ERROR",
186
189
  });
187
190
 
@@ -221,6 +224,7 @@ describe("#useServerEffect", () => {
221
224
  const fakeHandler = jest.fn();
222
225
  jest.spyOn(SsrCache.Default, "getEntry").mockReturnValueOnce({
223
226
  data: "DATA",
227
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'undefined'.
224
228
  error: null,
225
229
  });
226
230
 
@@ -237,7 +241,9 @@ describe("#useServerEffect", () => {
237
241
  // Arrange
238
242
  const fakeHandler = jest.fn();
239
243
  jest.spyOn(SsrCache.Default, "getEntry").mockReturnValueOnce({
244
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'null' is not assignable to type 'ValidCacheData'.
240
245
  data: null,
246
+ // @ts-expect-error [FEI-5019] - TS2322 - Type 'string' is not assignable to type 'undefined'.
241
247
  error: "ERROR",
242
248
  });
243
249
 
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import {renderHook as clientRenderHook} from "@testing-library/react-hooks";
3
2
 
4
3
  import {useSharedCache, SharedCache} from "../use-shared-cache";
@@ -14,7 +13,7 @@ describe("#useSharedCache", () => {
14
13
  ${""}
15
14
  ${5}
16
15
  ${() => "BOO"}
17
- `("should throw if the id is $id", ({id}) => {
16
+ `("should throw if the id is $id", ({id}: any) => {
18
17
  // Arrange
19
18
 
20
19
  // Act
@@ -30,7 +29,7 @@ describe("#useSharedCache", () => {
30
29
  ${""}
31
30
  ${5}
32
31
  ${() => "BOO"}
33
- `("should throw if the scope is $scope", ({scope}) => {
32
+ `("should throw if the scope is $scope", ({scope}: any) => {
34
33
  // Arrange
35
34
 
36
35
  // Act
@@ -49,6 +48,7 @@ describe("#useSharedCache", () => {
49
48
  } = clientRenderHook(() => useSharedCache("id", "scope"));
50
49
 
51
50
  // Assert
51
+ // @ts-expect-error [FEI-5019] - TS2339 - Property 'toBeArrayOfSize' does not exist on type 'JestMatchers<[ValidCacheData | null | undefined, CacheValueFn<ValidCacheData>]>'.
52
52
  expect(result).toBeArrayOfSize(2);
53
53
  });
54
54
 
@@ -110,7 +110,7 @@ describe("#useSharedCache", () => {
110
110
  it("should be the same function if the id and scope remain the same", () => {
111
111
  // Arrange
112
112
  const wrapper = clientRenderHook(
113
- ({id, scope}) => useSharedCache(id, scope),
113
+ ({id, scope}: any) => useSharedCache(id, scope),
114
114
  {initialProps: {id: "id", scope: "scope"}},
115
115
  );
116
116
 
@@ -123,14 +123,14 @@ describe("#useSharedCache", () => {
123
123
  const result2 = wrapper.result.current;
124
124
 
125
125
  // Assert
126
- // $FlowIgnore[prop-missing]
126
+ // @ts-expect-error [FEI-5019] - TS7053 - Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'Error | [ValidCacheData | null | undefined, CacheValueFn<ValidCacheData>]'.
127
127
  expect(result1[1]).toBe(result2[1]);
128
128
  });
129
129
 
130
130
  it("should be a new function if the id changes", () => {
131
131
  // Arrange
132
132
  const wrapper = clientRenderHook(
133
- ({id}) => useSharedCache(id, "scope"),
133
+ ({id}: any) => useSharedCache(id, "scope"),
134
134
  {
135
135
  initialProps: {id: "id"},
136
136
  },
@@ -142,14 +142,14 @@ describe("#useSharedCache", () => {
142
142
  const result2 = wrapper.result.current;
143
143
 
144
144
  // Assert
145
- // $FlowIgnore[prop-missing]
145
+ // @ts-expect-error [FEI-5019] - TS7053 - Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'Error | [ValidCacheData | null | undefined, CacheValueFn<ValidCacheData>]'.
146
146
  expect(result1[1]).not.toBe(result2[1]);
147
147
  });
148
148
 
149
149
  it("should be a new function if the scope changes", () => {
150
150
  // Arrange
151
151
  const wrapper = clientRenderHook(
152
- ({scope}) => useSharedCache("id", scope),
152
+ ({scope}: any) => useSharedCache("id", scope),
153
153
  {
154
154
  initialProps: {scope: "scope"},
155
155
  },
@@ -161,7 +161,7 @@ describe("#useSharedCache", () => {
161
161
  const result2 = wrapper.result.current;
162
162
 
163
163
  // Assert
164
- // $FlowIgnore[prop-missing]
164
+ // @ts-expect-error [FEI-5019] - TS7053 - Element implicitly has an 'any' type because expression of type '1' can't be used to index type 'Error | [ValidCacheData | null | undefined, CacheValueFn<ValidCacheData>]'.
165
165
  expect(result1[1]).not.toBe(result2[1]);
166
166
  });
167
167
 
@@ -186,7 +186,7 @@ describe("#useSharedCache", () => {
186
186
  value
187
187
  ${undefined}
188
188
  ${null}
189
- `("should purge the value from the cache if $value", ({value}) => {
189
+ `("should purge the value from the cache if $value", ({value}: any) => {
190
190
  // Arrange
191
191
  const wrapper = clientRenderHook(() =>
192
192
  useSharedCache("id", "scope"),
@@ -225,7 +225,7 @@ describe("#useSharedCache", () => {
225
225
  id
226
226
  ${"id1"}
227
227
  ${"id2"}
228
- `("should not share cache if scope is different", ({id}) => {
228
+ `("should not share cache if scope is different", ({id}: any) => {
229
229
  // Arrange
230
230
  const hook1 = clientRenderHook(() => useSharedCache("id1", "scope1"));
231
231
  const hook2 = clientRenderHook(() => useSharedCache(id, "scope2"));
@@ -243,7 +243,7 @@ describe("#useSharedCache", () => {
243
243
  scope
244
244
  ${"scope1"}
245
245
  ${"scope2"}
246
- `("should not share cache if id is different", ({scope}) => {
246
+ `("should not share cache if id is different", ({scope}: any) => {
247
247
  // Arrange
248
248
  const hook1 = clientRenderHook(() => useSharedCache("id1", "scope1"));
249
249
  const hook2 = clientRenderHook(() => useSharedCache("id2", scope));