Open FBurner opened 2 years ago
Any news on this issue?
Same, looking for some solution
@IgorKushnir @mi-mazouz @FBurner you can use getIn
function
If you have a wrapper around Fomik, you can mitigate this issue rather easily, by copy-pasting the type above from the source (for the latest version) and fixing it by removing the last bit as OP indicated. It now works correctly with nested fields. I'm not even sure why the string
type is even relevant. Would be great If someone can elaborate on a Formik usage that applies to it.
// https://github.com/jaredpalmer/formik/blob/c798145e2307b0273ea4d9c6bfd8250f28d95be9/packages/formik/src/types.tsx#L14
export type FormikErrors<Values> = {
[K in keyof Values]?: Values[K] extends any[]
? Values[K][number] extends object
? FormikErrors<Values[K][number]>[] | string | string[]
: string | string[]
: FormikErrors<Values[K]>;
};
Alternatively, you can use patch-package
(some package managers have this feature built-in) to fix it at the import level, which should be pretty easy.
Bug report
Current Behavior
Nested object when accessed via the dot operator gets following error:
TS2339: Property 'budget' does not exist on type 'string'.
Expected behavior
Not to throw this error
Reproducible example
Suggested solution(s)
Make it properly work with injected type.
Its the FormikErrors Type in formik/dist/types.d.ts:13
The last FormikErrors<Values[K]> : string; is causing the problem
Your environment