Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Migration path from current DefinitelyTyped RN typings #10

Description

@alloy

This ticket describes the differences with the existing manually maintained DT typings and the migration path to these converted ones.

  • TypeScript does not have a build in way to deal with different files for different platforms. Proposal: Allow typescript to type check modules using react-native's module resolution TypeScript#21926

    • How can we offer distinctive sets of typings for iOS and Android (eg @types/react-native-ios, @types/react-native-android) and let the user configure them for their project?
    • Can DT handle this?
    • And can other DT packages that depend on RN use this too?
  • Many (all?) components are no longer class based, but rather function or even ‘abstract’ based. Because classes can be used as types in TS, there may be user code that refers to it that way but now needs to change to typeof View. This does not seem like an issue we need to resolve, as it’s simply not in line with reality. TS2749

  • Component props interfaces are exported, whereas upstream Flow code requires the user to do React.ElementProps<typeof View>. We currently export these separate props types as a migration convenience, but they are annotated as being deprecated.

    • There are many more component props interfaces still missing.
    • Should we add ElementProps to the React DT typings and is it correct that ElementProps does not include ref (as we use ComponentPropsWithoutRef of the React DT typings)?
  • Allow interface merging of RN NativeModules. These contain the user's own and 3rd party native modules and so should allow for the user to provide typings. f41628c

  • Style type param passed to StyleSheet.create<T>(…) needs to by a type alias, not an interface; because Index signature is missing in type (only on interfaces, not on type alias) TypeScript#15300 (comment). But also there's no longer a need to define the type upfront anymore (which perhaps was already no longer needed).

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions