Skip to content

fix(Watch): correct render function parameter typing#13108

Merged
bluebill1049 merged 3 commits intoreact-hook-form:masterfrom
dusan233:fix-watch-component-typing
Oct 28, 2025
Merged

fix(Watch): correct render function parameter typing#13108
bluebill1049 merged 3 commits intoreact-hook-form:masterfrom
dusan233:fix-watch-component-typing

Conversation

@dusan233
Copy link
Copy Markdown
Contributor

fixes #13105

@bluebill1049
Copy link
Copy Markdown
Member

could you include some tests?

@dusan233
Copy link
Copy Markdown
Contributor Author

could you include some tests?

I moved the type assertions into a .test-d.ts file. Previously they existed in watch.test.tsx but didn’t run because expectType was used outside a .test-d.ts file.

@bluebill1049 bluebill1049 requested a review from Copilot October 28, 2025 01:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a TypeScript typing issue in the Watch component by adding the const modifier to the TFieldNames generic parameter. This change enables TypeScript to infer the exact tuple type of field names rather than widening them to a general array type, which improves type safety for the render function parameters.

  • Added const type parameter modifier to TFieldNames generic in the Watch component
  • Moved type tests from runtime test file to a dedicated TypeScript test file
  • Updated API documentation to reflect the signature change

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/watch.tsx Added const modifier to TFieldNames generic parameter to preserve literal tuple types
src/typetest/watch.test-d.ts Added new TypeScript-specific type test for verifying render function parameter types
src/tests/watch.test.tsx Removed runtime type test that was moved to dedicated type test file
reports/api-extractor.md.api.md Updated API signature documentation to reflect the const modifier addition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bluebill1049 bluebill1049 merged commit 384ad49 into react-hook-form:master Oct 28, 2025
6 checks passed
@mamlzy
Copy link
Copy Markdown

mamlzy commented Oct 31, 2025

@bluebill1049 Could you publish this pr? this issue is a blocker for me to use Watch component🙏

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.

issue: Watch component render function parameter typed as never

4 participants