Skip to content

Commit

Permalink
types: Allow auto-import by improving generated types (#2563)
Browse files Browse the repository at this point in the history
style: default export assigned variables
  • Loading branch information
oosawy committed Apr 14, 2023
1 parent 9371f1d commit a269839
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion core/use-swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,6 @@ export const unstable_serialize = (key: Key) => serialize(key)[0]
* }
* ```
*/
export default withArgs<SWRHook>(useSWRHandler)
const useSWR = withArgs<SWRHook>(useSWRHandler)

export default useSWR
4 changes: 3 additions & 1 deletion immutable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ export const immutable: Middleware = useSWRNext => (key, fetcher, config) => {
return useSWRNext(key, fetcher, config)
}

export default withMiddleware(useSWR, immutable)
const useSWRImmutable = withMiddleware(useSWR, immutable)

export default useSWRImmutable
4 changes: 3 additions & 1 deletion infinite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ export const infinite = (<Data, Error>(useSWRNext: SWRHook) =>
}
}) as unknown as Middleware

export default withMiddleware(useSWR, infinite) as SWRInfiniteHook
const useSWRInfinite = withMiddleware(useSWR, infinite) as SWRInfiniteHook

export default useSWRInfinite

export {
SWRInfiniteConfiguration,
Expand Down
7 changes: 6 additions & 1 deletion mutation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ const mutation = (<Data, Error>() =>
* } = useSWRMutation(key, fetcher, options?)
* ```
*/
export default withMiddleware(useSWR, mutation) as unknown as SWRMutationHook
const useSWRMutation = withMiddleware(
useSWR,
mutation
) as unknown as SWRMutationHook

export default useSWRMutation

export {
SWRMutationConfiguration,
Expand Down

0 comments on commit a269839

Please sign in to comment.