-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Proposal: Support React.Native Platform Specific Code #17681
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
Comments
looks like a duplicate of #8328 |
@mhegazy #8328 has not been solved and this is a LEGITIMATE issue. Files with extensions such as And not only for React Native which promotes file extensions as such, if custom extensions support is added, allowing for example |
I do not think there is a simple change that we can do to enable this scenario. The assumptions built on the file extensions goes deep in the system, if we were to enable this scenario we will have to handle this in input files, module resolution, type checking, language service and output generation. again this is not a simple change and rewiring the whole compiler is not something we can take lightly. In #8328 i have outlined a few workarounds. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
https://facebook.github.io/react-native/docs/platform-specific-code.html#platform-specific-extensions
React.Native's packager allows you to create multiple implementations of a module/file that are specific to target platforms. During build/package time it will pick up the right file based on the target platform. This is super useful.
TypeScript can play reasonably well with this by explicitly including all platform files during the build. However, you lose type safety since TypeScript will only really build against one of the files. For example:
This will compile correctly, but result in a runtime failure during an iOS execution. It would be great if we could specify the target platform and have the module resolver use that when evaluating which file to load.
Thoughts?
The text was updated successfully, but these errors were encountered: