Skip to content

Commit a269839

Browse files
authored
types: Allow auto-import by improving generated types (vercel#2563)
style: default export assigned variables
1 parent 9371f1d commit a269839

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

core/use-swr.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,4 +693,6 @@ export const unstable_serialize = (key: Key) => serialize(key)[0]
693693
* }
694694
* ```
695695
*/
696-
export default withArgs<SWRHook>(useSWRHandler)
696+
const useSWR = withArgs<SWRHook>(useSWRHandler)
697+
698+
export default useSWR

immutable/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ export const immutable: Middleware = useSWRNext => (key, fetcher, config) => {
1010
return useSWRNext(key, fetcher, config)
1111
}
1212

13-
export default withMiddleware(useSWR, immutable)
13+
const useSWRImmutable = withMiddleware(useSWR, immutable)
14+
15+
export default useSWRImmutable

infinite/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ export const infinite = (<Data, Error>(useSWRNext: SWRHook) =>
324324
}
325325
}) as unknown as Middleware
326326

327-
export default withMiddleware(useSWR, infinite) as SWRInfiniteHook
327+
const useSWRInfinite = withMiddleware(useSWR, infinite) as SWRInfiniteHook
328+
329+
export default useSWRInfinite
328330

329331
export {
330332
SWRInfiniteConfiguration,

mutation/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ const mutation = (<Data, Error>() =>
146146
* } = useSWRMutation(key, fetcher, options?)
147147
* ```
148148
*/
149-
export default withMiddleware(useSWR, mutation) as unknown as SWRMutationHook
149+
const useSWRMutation = withMiddleware(
150+
useSWR,
151+
mutation
152+
) as unknown as SWRMutationHook
153+
154+
export default useSWRMutation
150155

151156
export {
152157
SWRMutationConfiguration,

0 commit comments

Comments
 (0)