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

fix: form #737

Merged
merged 1 commit into from
May 25, 2023
Merged

fix: form #737

merged 1 commit into from
May 25, 2023

Conversation

jc9702507
Copy link
Collaborator

@jc9702507 jc9702507 commented May 24, 2023

  • 添加是要是没有使用component2就报错

@github-actions
Copy link
Contributor

github-actions bot commented May 24, 2023

🎊 PR Preview 25dbf24 has been successfully built and deployed to https://ant-design-ant-design-mini-preview-pr-737.surge.sh

🕐 Build time: 255.447s

🤖 By surge-preview

const component2 = my.canIUse('component2');
if (!component2) {
throw new Error('需要使用component2');
}
this.setInitialValues(formConfig.initialValues || {});
this.setRules(formConfig.rules || {});
this.validateMessages = formConfig.validateMessages;
Copy link
Contributor

Choose a reason for hiding this comment

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

这是一个 TypeScript 类的代码片段,对 Form 类的构造函数进行了修改。主要改动如下:

  1. 新增了分类判断 component2 是否支持,并在不支持时抛出错误。
  2. 给表单设置了初始值和验证规则,并允许自定义验证提示信息。

代码看起来没有明显的 bug 风险,但仍有以下几点可以改进:

  1. 抛出的错误信息比较简单,建议给出更具体的错误信息,例如告诉用户是哪个组件或哪个 API 不支持 component2。
  2. 没有提供针对 validateMessages 属性的自定义方法,建议添加该方法以便在验证失败时可以输出更符合业务需求的提示信息。
  3. 应该考虑加入 Eslint 或 Prettier 等代码格式化工具,以保证代码风格的统一和可维护性。

@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.02 ⚠️

Comparison is base (0738a71) 24.01% compared to head (25dbf24) 24.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #737      +/-   ##
==========================================
- Coverage   24.01%   24.00%   -0.02%     
==========================================
  Files         158      158              
  Lines        3339     3341       +2     
  Branches      875      876       +1     
==========================================
  Hits          802      802              
- Misses       2206     2207       +1     
- Partials      331      332       +1     
Impacted Files Coverage Δ
src/Collapse/index.ts 0.00% <ø> (ø)
src/Form/form.ts 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wyj580231 wyj580231 merged commit 460c8e2 into master May 25, 2023
@github-actions github-actions bot mentioned this pull request May 25, 2023
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.

2 participants