T
TanStack6mo ago
sensitive-blue

[TypeScript] Passing field.state.meta.errors to child component

Trying to figure out what the type is for field.state.meta.errors to properly type a child component. It appears to be StandardSchemaV1Issue[] when you inspect the individual objects but when passing it to the child, I get a TypeScript error like this:
Type 'UnwrapOneLevelOfArray<UnwrapFieldValidateOrFn<{ email: string; password: string; }, "email", FieldValidateOrFn<{ email: string; password: string; }, "email", string> | undefined, ZodObject<{ email: ZodString; password: ZodString; }, "strip", ZodTypeAny, { ...; }, { ...; }>>>[]' is not assignable to type 'StandardSchemaV1Issue[]'.
Type 'UnwrapOneLevelOfArray<UnwrapFieldValidateOrFn<{ email: string; password: string; }, "email", FieldValidateOrFn<{ email: string; password: string; }, "email", string> | undefined, ZodObject<{ email: ZodString; password: ZodString; }, "strip", ZodTypeAny, { ...; }, { ...; }>>>' is not assignable to type 'StandardSchemaV1Issue'.
Type 'undefined' is not assignable to type 'StandardSchemaV1Issue'.
Type 'UnwrapOneLevelOfArray<UnwrapFieldValidateOrFn<{ email: string; password: string; }, "email", FieldValidateOrFn<{ email: string; password: string; }, "email", string> | undefined, ZodObject<{ email: ZodString; password: ZodString; }, "strip", ZodTypeAny, { ...; }, { ...; }>>>[]' is not assignable to type 'StandardSchemaV1Issue[]'.
Type 'UnwrapOneLevelOfArray<UnwrapFieldValidateOrFn<{ email: string; password: string; }, "email", FieldValidateOrFn<{ email: string; password: string; }, "email", string> | undefined, ZodObject<{ email: ZodString; password: ZodString; }, "strip", ZodTypeAny, { ...; }, { ...; }>>>' is not assignable to type 'StandardSchemaV1Issue'.
Type 'undefined' is not assignable to type 'StandardSchemaV1Issue'.
2 Replies
sensitive-blue
sensitive-blueOP6mo ago
Thank you. That "works" but there's no type information. I feel like I should be able to pass a type as an argument to FieldMeta. Or I guess the real issue is that when you do that, I try to access an element of the errors array and they're typed as any. Shouldn't it be a StandardSchemaV1Issue?

Did you find this page helpful?