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

types/request service #1011

Merged
merged 2 commits into from
Jul 7, 2021
Merged

Conversation

maoxiaoke
Copy link
Contributor

当使用 use-request 传入 object 时,缺乏类型提示

const { loading, run } = useRequest((username) => ({
  url: '/api/changeUsername',
  method: 'post',
  body: JSON.stringify({ username }),
}))

有关 issue - ice-4417

Copy link
Collaborator

@brickspert brickspert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@brickspert brickspert merged commit 27d7588 into alibaba:master Jul 7, 2021
@yckbilly1929
Copy link

after updating to 2.10.7, there will be a false positive type error for custom request method, as shown below:

Screenshot from 2021-07-10 10-55-03

Argument of type '(values: SubmitForm) => SubmitForm' is not assignable to parameter of type 'CombineService<DemoRes, [SubmitForm]>'.
  Type '(values: SubmitForm) => SubmitForm' is not assignable to type '(args_0: SubmitForm) => RequestService'.
    Type 'SubmitForm' is not assignable to type 'RequestService'.
      Property 'url' is missing in type 'SubmitForm' but required in type 'RequestServiceObject'.ts(2345)
types.d.ts(9, 14): 'url' is declared here.
(parameter) values: SubmitForm

in our case, url is not needed as the data fetching logic is put into another separate hook file (it may deal with different datasource and client side discovery)

or shall we put commonly used fields as optional?

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

Successfully merging this pull request may close these issues.

3 participants