React-native-web: Platform-specific file extensions with Typescript - manual solution

Created on 6 Feb 2018  Â·  4Comments  Â·  Source: necolas/react-native-web

Do you want to request a feature or report a bug?
_Feature (..ish)_

What is the current behavior?
_File splitting via platform-specific file extensions such as .web is not compatible with Typescript, since TS needs to follow the full compile-time path and wants a hard import reference_

Demo

https://github.com/mosesoak/react-native-web-ts-app

It works! But requires that you package a split component with a vanilla .js file that does the import splitting, then re-export it with a typecast interface from a .tsx file.

Q: Anyone have what it takes to a piece of magic to make this work under the hood?

Or perhaps there's a better way to do this, let me know! 😄

PS @necolas Thanks for RNW, it's great!

Most helpful comment

@necolas sorry for the slop. Set public and edited for clarity.

Note that this is not a bug report, but was hoping to generate some discussion around it, so please reopen the issue as you see fit. Thanks again, really enjoying your work and hope this contributes

All 4 comments

I have no idea what this is about, and the link is a 404 ¯\_(ツ)_/¯

@necolas sorry for the slop. Set public and edited for clarity.

Note that this is not a bug report, but was hoping to generate some discussion around it, so please reopen the issue as you see fit. Thanks again, really enjoying your work and hope this contributes

Might be worth bringing up with CRA if there is missing typescript or webpack support

@mosesoak This is amazing, thank you!

Was this page helpful?
0 / 5 - 0 ratings