Closed
Description
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:
// foo.ts
export const color = "red"
// foo.ios.ts
export const colour = "blue" // British spelling!
// bar.ts
import { color } from "foo"
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?