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

Widen JSX callback type #204

Open
samhh opened this issue Mar 28, 2024 · 0 comments
Open

Widen JSX callback type #204

samhh opened this issue Mar 28, 2024 · 0 comments

Comments

@samhh
Copy link
Contributor

samhh commented Mar 28, 2024

With the tsx backend we currently type everything relevant as ReactElement. This generally makes sense as it's stricter than ReactNode, however we actually could permit consumers to return ReactNode in callbacks. We've observed an occasional need to wrap something assignable to ReactNode in unnecessary fragments to workaround this issue.

Example of expected change:

-export const f: (x: { g: (x: ReactElement) => ReactElement }) => ReactElement = x => <>foo {x.g(<>bar</>)}</>
+export const f: (x: { g: (x: ReactElement) => ReactNode    }) => ReactElement = x => <>foo {x.g(<>bar</>)}</>

It should be noted in Unsplash Web specifically this may pose issues with our fancy custom internationalisation types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant