unsplash / intlc

Compile ICU messages into code. Supports TypeScript and JSX. No runtime.
MIT License
56 stars 2 forks source link

Widen JSX callback type #204

Open samhh opened 5 months ago

samhh commented 5 months ago

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.