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

feat: optimize useRequest data return type of typescript #237 #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

XiaoDaiGua-Ray
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese y

优化返回 data 值的类型推导,现在满足以下的原则:

  1. 如果配置了 initialData,未配置 formatResultdata 类型则为 service 方法的返回值,不联合 undefined 类型
  2. 如果配置了 formatResult,未配置 initialDatadata 类型则为 formatResult 的返回值类型,data 会联合 undefined 类型
  3. 如果同时配置了 initialData, formatResult,那么 data 的值以 formatResult 的返回值类型为准,并且 data 会联合 undefined 类型

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Follow our Code of Conduct
  • Read the Contributing Guidelines
  • Read the docs
  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@XiaoDaiGua-Ray XiaoDaiGua-Ray changed the title feat: optimize useRequest data return type of typescript feat: optimize useRequest data return type of typescript #237 Jan 15, 2025
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.

1 participant