Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useRequest 对默认参数的类型推导有问题 #2671

Open
linzhipeng98 opened this issue Nov 11, 2024 · 2 comments
Open

useRequest 对默认参数的类型推导有问题 #2671

linzhipeng98 opened this issue Nov 11, 2024 · 2 comments

Comments

@linzhipeng98
Copy link

const { data, error, loading } = useRequest(async(a = 1, b = 1) => {
  return null
});

这时候 ab 的类型为 any

@crazylxr
Copy link
Collaborator

a 和 b 是入参,在哪里需要消费入参的类型?

@linzhipeng98
Copy link
Author

a 和 b 是入参,在哪里需要消费入参的类型?

const { run } = useRequest(async(a = 1, b = 1) => {
  return null
});

// 手动调用 run 方法
const a = '1'
run(a) // 这时候类型错误无提示,a 被推导成了 `any`

@crazylxr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants