rnx-kit icon indicating copy to clipboard operation
rnx-kit copied to clipboard

TypeScript support for react-native

Open afoxman opened this issue 2 years ago • 1 comments

Add react-native support to TypeScript. Problem is demonstrated and explained in https://github.com/afoxman/rnts-example.

  • [x] Update the TypeScript resolver: https://github.com/microsoft/TypeScript/pull/48189
  • [ ] Module name substitution -- still in design discussions: https://github.com/microsoft/TypeScript/issues/48095

afoxman avatar Mar 20 '22 07:03 afoxman

Followup: What's missing now is getting types for the target platform when the import/require is for 'react-native' (e.g. react-native-windows, which has types in its core package).

Met with the TypeScript team, and it sounds like we can get this without further TS core changes. Rough plan is to move everything to @types packages and use existing path/baseurl mapping to make it work. Andrew Branch is going to help when I find time to dig in further. One big step that he pointed out is the need to avoid "links" between types packages -- e.g. RNW types import RN types. This won't work with the remapping system. This means moving every RN platform to its own @types/... package.

afoxman avatar May 10 '22 16:05 afoxman

react-native is now shipping types.

tido64 avatar Jul 21 '23 14:07 tido64