TypeScript error with platform-specific file extension when components need different props?

Im using platform specific file extensions. If the platform is web then a ref is not needed, but for both Android and iOS it is. It seems TypeScript isn’t aware of how this works and is giving me a prop types error:

  ref={Platform.OS === "web" ? null : childRef}

I could use a ternary operator to use the right component, however presumably then both components would be loaded leading to a needlessly larger bundle size?:

{ Platform.OS === "web" ? <MyWebComponent foo={bar} /> : <MyNativeComponent foo={bar} ref={childRef} /> }

My project uses expo version ^37.0.0 and my CLI version is: 3.17.20.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.