Open
Description
Right now all of the custom argument types that can be given to the promiseFn
property are type of any.
Meaning when someone else tries to re-use your code, they can not know what types they should provide.
Example:
export const useJoinWaitlist = () => {
return useAsync({
promiseFn: ({ email }) =>
getClient()
.post<JoinWaitlistResponse>("/waitlist/join", { email })
.then((r) => r.data),
})
}
In this case, the type of email
is of any
Suggetion
It would be nice to have the option to provide the argument types of the promiseFn
export const useJoinWaitlist = () => {
type Args = {
email: string
}
return useAsync<JoinWaitlistResponse, Args>({
promiseFn: ({
// Email type is now defined and is of type `string`
email,
}) =>
getClient()
.post<JoinWaitlistResponse>("/waitlist/join", { email })
.then((r) => r.data),
})
}
Metadata
Metadata
Assignees
Labels
No labels