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

Revert type changes from #1088 #1223

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

Conversation

jnoordsij
Copy link

This reverts commit 9545160.

Summary

In #1088 a generic key, any combination was added to BaseValidation. This allows one to use arbitrary possibly incorrect accessing of properties on v$ (say v$.somethingThatDoesNotExist) without TypeScript errors, given that TypeScript infers any and basically stops checking. Therefore I think the introduced change degrades the quality of the types in this package.

The issue as presented in #1088 seems to be caused not by an incorrect typing in the type declarations, but rather by a missing generic argument, as seems to be implied by the listed Validation<ValidationArgs<unknown>, unknown> type description. If one ensures that in the scope of e.g. useVuelidate the generic T for the state argument is properly detected, actual values should be properly accessible on the resulting object.

Metadata

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes (theoretically for people relying on the new broken behavior; limited to TypeScript failure as there are no runtime changes)
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@jnoordsij
Copy link
Author

@tomosterlund I'm wondering if the alternative solution for your previous issue (i.e. #1088) as I've tried to describe above will solve it without needing your change, with the additional benefit of actually having proper types on the accessed properties. Would be great to have your input on this!

@tomosterlund
Copy link
Contributor

tomosterlund commented Feb 6, 2024

@jnoordsij I'm no longer developing any app with Vuelidate, so I won't have the use case to try it out. But if the same problem can be solved by generics and without losing type safety, it sounds like the right choice!

My PR from 2022 has to be seen in the light of being created by a TS-noob who at that point didn't know generics :) Thanks for including me your considerations though.

@jnoordsij
Copy link
Author

@jnoordsij I'm no longer developing any app with Vuelidate, so I won't have the use case to try it out. But if the same problem can be solved by generics and without losing type safety, it sounds like the right choice!

My PR from 2022 has to be seen in the light of being created by a TS-noob who at that point didn't know generics :) Thanks for including me your considerations though.

Thanks for writing back, I think reverting this should be the way forward then!

@dobromir-hristov given my encountered issue and the reaction above, do you think it's possible to move forward with this?

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.

None yet

2 participants