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

issue: Issues with touchedFields typing after upgrading to TypeScript 5.4 #11603

Open
1 task done
sashamorozov opened this issue Mar 7, 2024 · 4 comments
Open
1 task done
Labels
dependency Other library is not compatible TS Typescript related issues

Comments

@sashamorozov
Copy link

sashamorozov commented Mar 7, 2024

Version Number

7.51.0

Codesandbox/Expo snack

https://www.typescriptlang.org/play?ts=5.4.2#code/JYWwDg9gTgLgBDAnmApnA3nAYtEBlGAQxhQBptgUAbAEwAViALcrS2gNUKoFcUBnOAF84AMygQQcAERQUhAMYwAtIwgQA1kpG4pAbgBQ++RAB2feAHMUMAKJRxUOAF44AHgAqrajU49+cFAAPEhMaAS8OLl4+ck82GgA5QhA0IJCwim8GGEYPCJ8o-gA+IoAKfThRXAAubFwCYhQ8+N9ootIKuBNklFq47ySU-QBKZyKMTuAROFKAQlntKBAAOhR7aD4AbW6UgF04ADIDmfnFlZgIbnlGFBp8rZ2UfYAfZ6ql5eA+PG4AIxBgDASDRhqN0J1KrIYNwoCZ3is1g4Hj1dgB+ZYpPh8QhWTqCTpQmFw7ihFAiYAmW76QS6IA

Steps to reproduce

Hello,

I've encountered an issue with the typing of the touchedFields property in react-hook-form after updating to TypeScript 5.4. It seems that the new version of TypeScript has changed the way types are interpreted or handled, causing the types related to touchedFields to now throw compilation errors.

A code example demonstrating the issue is available in TypeScript Sandbox

TS Error

error TS2536: Type 'TFieldName' cannot be used to index type 'Partial<Readonly<DeepMap<DeepPartial<TFieldValues>, boolean>>>'.

It would be greatly appreciated if you could look into this issue and suggest a solution or workaround.

Thank you in advance for your attention to this matter. I look forward to your response.

Best regards,
Aleksandr

Expected behaviour

After upgrading to TypeScript 5.4, the touchedFields property should continue to work without any typing issues

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@bluebill1049 bluebill1049 added the TS Typescript related issues label Mar 7, 2024
@bluebill1049
Copy link
Member

This breaking change is coming from TS not this lib.

@hybs123
Copy link

hybs123 commented Mar 8, 2024

TFieldName is extracting the names of the touched fields as string but somehow TS is not able to index touchedFields in the form.

@VictorGosse
Copy link

Hello,
I confirm that we are facing the exact same issue and I'm wondering if it might come from https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/#more-aggressive-reduction-of-intersections-between-type-variables-and-primitive-types somehow.

@Lexe003
Copy link

Lexe003 commented Mar 14, 2024

Same issue here with dirtyFields

@bluebill1049 bluebill1049 added the dependency Other library is not compatible label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency Other library is not compatible TS Typescript related issues
Projects
None yet
Development

No branches or pull requests

5 participants