Closed v-angolenko closed 8 months ago
Thanks for reporting this, this makes sense. While there is no good way to type this without using unknown
here, but at the moment, defineField
doesn't care about the event arg at all so it is safe to remove the arg all together which would make it compatible with components.
What happened?
In the latest update of vee-validate, the defineField function has been introduced to define form fields and generate props for input elements. However, the types of the onInput and onChange methods in the generated props are strictly typed to accept only an Event object as their argument.
Expected Behavior: In some UI libraries, such as Element Plus (ElInput), the onInput and onChange methods expect the first argument to be the input value, not an Event object. This results in TypeScript errors when trying to use the generated props with these input components.
Suggested Solution: To make vee-validate more flexible and compatible with various UI libraries, it would be helpful to allow the onInput and onChange methods in the generated props to accept both an Event object and the input value as arguments. This would accommodate different use cases and prevent TypeScript errors when using vee-validate with libraries like Element Plus.
Reproduction steps
defineField
function, for example:titleProps
with an Element PlusElInput
component, like this:onInput
andonChange
methods. Element Plus expects the first argument of these methods to be the input value, not anEvent
object.Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
-
Code of Conduct