Skip to content

feat: refactor useWatch type #608

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

Closed
wants to merge 3 commits into from

Conversation

crazyair
Copy link
Contributor

@crazyair crazyair commented Aug 2, 2023

No description provided.

@vercel
Copy link

vercel bot commented Aug 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
field-form ❌ Failed (Inspect) Aug 2, 2023 2:10am

@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Merging #608 (ebc2200) into master (a1523e2) will not change coverage.
The diff coverage is n/a.

❗ Current head ebc2200 differs from pull request most recent head 3fb88ef. Consider uploading reports for the commit 3fb88ef to get more accurate results

@@           Coverage Diff           @@
##           master     #608   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files          15       15           
  Lines        1142     1142           
  Branches      245      245           
=======================================
  Hits         1140     1140           
  Misses          2        2           
Files Changed Coverage Δ
src/useWatch.ts 97.77% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -13,18 +13,26 @@ export type DeepNamePath<
? ParentNamePath['length'] extends 0
? Store | BaseNamePath // Return `BaseNamePath` instead of array if `ParentNamePath` is empty
: Store extends any[]
? [...ParentNamePath, number] // Connect path
? readonly [...ParentNamePath, number] // Connect path
Copy link
Member

Choose a reason for hiding this comment

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

这里为什么要加 readonly?

Copy link
Contributor Author

@crazyair crazyair Aug 2, 2023

Choose a reason for hiding this comment

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

@@ -271,10 +271,28 @@ describe('useWatch', () => {
const demo3 = Form.useWatch(['demo1', 'demo2', 'demo3'], form);
const demo4 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4'], form);
const demo5 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4', 'demo5'], form);
const more = Form.useWatch(['age', 'name', 'gender'], form);
const demo6 = Form.useWatch(['demo1', 'demo2', 'demo3', 'demo4', 'demo5', 'demo6'], form);
Copy link
Member

Choose a reason for hiding this comment

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

这里测试不会有效果,要加个类型推断做匹配:

const demoX: XXX = Form.useWatch(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

要加ts报错的测试吗

@crazyair crazyair closed this Aug 3, 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