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
Are you submitting a bug report or a feature request?
What is the current behavior?
FieldRenderProps includes an index signature that incorrectly assumes the matching object can have any number of fields beyond input and meta. If you define a component whose props extend FieldRenderProps, you end up including the index signature which allows any prop to be passed into the component even if it is untyped and unused. This is not type safe and can result in missed prop handling.
What is the expected behavior?
FieldRenderProps should not have an index signature included in its type since input and meta are the only two values explicitly defined within the field.
React Final Form v6.5.9
Final Form v4.20.7
TypeScript v4.6.2
Other information
The FieldRenderProps interface includes an index signature. However, this index signature is unnecessary to how the type is used and results in poor type safety when used.
The interface is used for two pieces of the API, the Field component and the useField hook.
The useField type returns FieldRenderProps but the code explicitly returns only input and meta. Thus, the index signature serves no purpose here.
The Field component uses FieldRenderProps to ensure that the props of the rendered component extend FieldRenderProps. In this context, the index signature also doesn't provide any benefit because a type with extra props will still extend FieldRenderProps (example TS sandbox)
The text was updated successfully, but these errors were encountered:
Are you submitting a bug report or a feature request?
What is the current behavior?
FieldRenderProps
includes an index signature that incorrectly assumes the matching object can have any number of fields beyondinput
andmeta
. If you define a component whose props extendFieldRenderProps
, you end up including the index signature which allows any prop to be passed into the component even if it is untyped and unused. This is not type safe and can result in missed prop handling.What is the expected behavior?
FieldRenderProps
should not have an index signature included in its type sinceinput
andmeta
are the only two values explicitly defined within the field.Sandbox Link
TypeScript sandbox with incorrect behavior
What's your environment?
React Final Form v6.5.9
Final Form v4.20.7
TypeScript v4.6.2
Other information
The
FieldRenderProps
interface includes an index signature. However, this index signature is unnecessary to how the type is used and results in poor type safety when used.The interface is used for two pieces of the API, the
Field
component and theuseField
hook.The
useField
type returnsFieldRenderProps
but the code explicitly returns onlyinput
andmeta
. Thus, the index signature serves no purpose here.The
Field
component usesFieldRenderProps
to ensure that the props of the rendered component extendFieldRenderProps
. In this context, the index signature also doesn't provide any benefit because a type with extra props will still extendFieldRenderProps
(example TS sandbox)The text was updated successfully, but these errors were encountered: