You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TypeScript generic for the yupResolver does not provide strong typings for the form data.
I expected event.values.password to be strongly typed due to providing FormData to yupResolver<FormData>.
If that is not the purpose of the yupResolver generic, then how do we get strong typings?
<template>
<Form@submit="handleSubmitPasswordReset":resolver="validationResolver":initalValues="initalValues"v-slot="$form"
>
<divclass="flex flex-col gap-1">
<FloatLabelvariant="on">
<VPasswordid="password"name="password"toggle-mask@strength-rating="passwordStrengthRating = $event"
/>
<VLabelrequiredhtml-for="password">New Password</VLabel>
</FloatLabel>
<VFieldErrorv-if="$form.password?.invalid">
{{ $form.password.error.message }}
</VFieldError>
</div>
<Button:loading="isLoading":disabled="!$form.password.value"label="Submit"type="submit"class="w-full"
/>
</Form>
</template>
<script setup lang="ts">
import { Form } from'@primevue/forms';import { yupResolver } from'@primevue/forms/resolvers/yup';typeFormData= { password:string|null;};const initalValues:FormData= { password: null,};const ValidationSchema =object({ password: string().required('Password is required'),});const validationResolver =yupResolver<FormData>(ValidationSchema);const handleSubmitPasswordReset =async (event:FormSubmitEvent) => {if (event.valid) {// This 'password' property has weak typing with an 'any' type// It should be 'string | null' because we have provided strong// typings using FormData. Would also be good if '$form.password'// was strongly typed in the template.console.log('Doing a password reset here...', event.values.password); }};
</script>
Open the reproduction in a TypeScript environment. Not sure if the provided reproduction has TypeScript? I couldn't find a TypeScript PrimeVue StackBlitz to use.
See that event.values.password is not strongly typed
Expected behavior
event.values.password should be strongly typed
The text was updated successfully, but these errors were encountered:
Describe the bug
The TypeScript generic for the
yupResolver
does not provide strong typings for the form data.I expected
event.values.password
to be strongly typed due to providingFormData
toyupResolver<FormData>
.If that is not the purpose of the yupResolver generic, then how do we get strong typings?
Pull Request Link
No response
Reason for not contributing a PR
Other Reason
No response
Reproducer
https://stackblitz.com/edit/ywanqa7v-vqn3w9ya?file=src%2FApp.vue
Environment
TypeScript, Vue 3, PrimeVue 4.3.1
Vue version
3.5.13
PrimeVue version
4.3.1
Node version
No response
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
event.values.password should be strongly typed
The text was updated successfully, but these errors were encountered: