Given the Yup validation schema for the jobLevel field. The error could be either a string errors.jobLevel or errors.jobLevel?.id but I get an error Property 'id' does not exist on type 'never'.
Expected behavior
Correct type inference for typescript to handle both string and object types.
Reproducible example
Validation schema can be found in App.tsx. If you look at Field.tsx example you'd be able to see the type error.
Bug report
Current Behavior
Given the
Yup
validation schema for thejobLevel
field. The error could be either a stringerrors.jobLevel
orerrors.jobLevel?.id
but I get an errorProperty 'id' does not exist on type 'never'.
Expected behavior
Correct type inference for typescript to handle both string and object types.
Reproducible example
Validation schema can be found in
App.tsx
. If you look atField.tsx
example you'd be able to see the type error.https://codesandbox.io/p/sandbox/formik-type-issue-jhgpj3
Suggested solution(s)
Additional context
Your environment