Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve getNativeFormProps in bridges to a more specific type #1212

Closed
wadamek65 opened this issue Jan 30, 2023 · 1 comment · Fixed by #1325
Closed

Improve getNativeFormProps in bridges to a more specific type #1212

wadamek65 opened this issue Jan 30, 2023 · 1 comment · Fixed by #1325
Labels
Area: Bridge Affects some of the bridge packages Bridge: GraphQL Affects the uniforms-bridge-graphql package Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Bridge: SimpleSchema (v2) Affects the uniforms-bridge-simple-schema-2 package Bridge: SimpleSchema Affects the uniforms-bridge-simple-schema package Bridge: Zod Affects the uniforms-bridge-zod package Type: Feature New features and feature requests
Milestone

Comments

@wadamek65
Copy link
Contributor

In #1044 the types of getNativeFormProps methods in bridges were improved. I believe we can add more exact typings to the returned value here by also specifying the children prop type. Possibly other form props as well? Perhaps we could base the type on the native form prop types provided by React and omit all the necessary properties. Method in question.

Example problematic case when creating a custom Form component by extending the BaseForm:

	public render() {
		const {children} = this.getNativeFormProps()
		return (
			<div>
				{children}
			</div>
		)
	}

which produces the following type error:

TS2322: Type 'unknown' is not assignable to type 'ReactNode'.   Type 'unknown' is not assignable to type 'ReactPortal'.
@wadamek65 wadamek65 added Type: Feature New features and feature requests Area: Bridge Affects some of the bridge packages Bridge: GraphQL Affects the uniforms-bridge-graphql package Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Bridge: SimpleSchema Affects the uniforms-bridge-simple-schema package Bridge: SimpleSchema (v2) Affects the uniforms-bridge-simple-schema-2 package Bridge: Zod Affects the uniforms-bridge-zod package labels Jan 30, 2023
@radekmie radekmie added this to the v4.0 milestone Feb 3, 2023
@radekmie
Copy link
Contributor

radekmie commented Feb 3, 2023

To make it clear: we did that in the first place, because of React Native compatibility. But as this is a rather small percentage of uniforms users, we can make it easier for the rest at a cost of some unused typings in RN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Bridge Affects some of the bridge packages Bridge: GraphQL Affects the uniforms-bridge-graphql package Bridge: JSON Schema Affects the uniforms-bridge-json-schema package Bridge: SimpleSchema (v2) Affects the uniforms-bridge-simple-schema-2 package Bridge: SimpleSchema Affects the uniforms-bridge-simple-schema package Bridge: Zod Affects the uniforms-bridge-zod package Type: Feature New features and feature requests
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants