Extend emit-as-interface coverage for Uniwind compatibility (#56811)#56811
Open
huntie wants to merge 2 commits into
Open
Extend emit-as-interface coverage for Uniwind compatibility (#56811)#56811huntie wants to merge 2 commits into
huntie wants to merge 2 commits into
Conversation
|
@huntie has exported this pull request. If you are a Meta employee, you can view the originating Diff in D105028014. |
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
huntie
added a commit
to huntie/react-native
that referenced
this pull request
May 14, 2026
…#56811) Summary: Pull Request resolved: facebook#56811 Extends the set of component props types annotated with `build-types emit-as-interface` to cover all types augmented by Uniwind. This is a follow-up to D104808984, which added coverage for NativeWind and Expo. The additional types converted to `interface` declarations are: * `ActivityIndicatorProps` * `ButtonProps` * `ImageBackgroundProps` * `KeyboardAvoidingViewProps` * `ModalBaseProps` * `PressableProps` * `RefreshControlProps` * `SectionListProps` * `TextInputProps` * `TextProps` * `TouchableHighlightProps` See https://github.com/uni-stack/uniwind/blob/a2406b8e04f5597b32a44febe01159c5223ee3c6/packages/uniwind/types.d.ts. Changelog: [General][Changed] - **Strict TypeScript API**: Additional component props types are now `interface` declarations, enabling module augmentation by libraries like Uniwind (preserve compatibility) Differential Revision: D105028014
…6809) Summary: #### Motivation Adds (preserves) compatibility of Nativewind and Expo Web type augmentations with the Strict TypeScript API. - These libraries rely on key React Native component types being defined as `interface`, not `type`, since TS module augmentation only supports `interface` declarations. - Previously, our opt-in generated TypeScript types (Strict TypeScript API) emitted all props types as `type Foo = Readonly<...>` ), matching Flow source. However, this API change vs our manual types (which predominantly used `interface` on props) breaks library compatibility in these cases. - This is very awkward to otherwise solve in user space — so opt for backwards compatibility in our new types. #### Primer TypeScript module augmentation lets a library extend an existing module's types without modifying the source. e.g. In Nativewind ([source](https://www.nativewind.dev/docs/guides/third-party-components)): ```ts declare module 'react-native' { interface ScrollViewProps extends ViewProps, ScrollViewPropsIOS, ScrollViewPropsAndroid, Touchable { contentContainerClassName?: string; indicatorClassName?: string; } interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> { columnWrapperClassName?: string; } interface ViewProps { className?: string; } } ``` Expo's `react-native-web.d.ts` ([source](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts)) also follows the same pattern across several component props types. #### Changes Add new `build-types` transform, implementing an opt-in `/** build-types emit-as-interface */` annotation, converting eligible `type` aliases to `interface` declarations. - Changing the Flow source files directly isn't viable — Flow doesn't support `interface extends Omit<>`, and several of these types use `Omit<>` in their composition. The post-transform operates on the TypeScript output where `interface extends Readonly<Omit<...>>` is valid. The following emitted types are updated: | Type | Augmented by | Source | |---|---|---| | `ViewProps` | `className?` | [Nativewind](https://www.nativewind.dev/docs/guides/third-party-components), [Expo](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts) | | `ScrollViewProps` | `contentContainerClassName?`, `indicatorClassName?` | [Nativewind](https://www.nativewind.dev/docs/guides/third-party-components) | | `ImagePropsBase` | `className?` | [Expo](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts) | | `SwitchProps` | `className?` | [Expo](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts) | | `TouchableWithoutFeedbackProps` | `className?` | [Expo](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts) | | `InputAccessoryViewProps` | `className?` | [Expo](https://unpkg.com/expo@54.0.31/types/react-native-web.d.ts) | `FlatListProps` is not included in this PR: its bare intersection (no `Readonly<>` wrapper) has a conflicting `fadingEdgeLength` property across constituent types that cannot be expressed as a single `extends` clause without hitting TS2320. This will be addressed in a follow-up. `VirtualizedListWithoutRenderItemProps<T>` in `react-native/virtualized-lists` is separately owned and not changed here. Changelog: [General][Changed] - **Strict TypeScript API**: Select component props types are now `interface` declarations, enabling module augmentation by libraries like NativeWind and Expo (preserve compatibility) Differential Revision: D104808984
…#56811) Summary: Extends the set of component props types annotated with `build-types emit-as-interface` to cover all types augmented by Uniwind. This is a follow-up to D104808984, which added coverage for NativeWind and Expo. The additional types converted to `interface` declarations are: * `ActivityIndicatorProps` * `ButtonProps` * `ImageBackgroundProps` * `KeyboardAvoidingViewProps` * `ModalBaseProps` * `PressableProps` * `RefreshControlProps` * `SectionListProps` * `TextInputProps` * `TextProps` * `TouchableHighlightProps` See https://github.com/uni-stack/uniwind/blob/a2406b8e04f5597b32a44febe01159c5223ee3c6/packages/uniwind/types.d.ts. Changelog: [General][Changed] - **Strict TypeScript API**: Additional component props types are now `interface` declarations, enabling module augmentation by libraries like Uniwind (preserve compatibility) Differential Revision: D105028014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Extends the set of component props types annotated with
build-types emit-as-interfaceto cover all types augmented by Uniwind.This is a follow-up to D104808984, which added coverage for NativeWind and Expo. The additional types converted to
interfacedeclarations are:ActivityIndicatorPropsButtonPropsImageBackgroundPropsKeyboardAvoidingViewPropsModalBasePropsPressablePropsRefreshControlPropsSectionListPropsTextInputPropsTextPropsTouchableHighlightPropsSee https://github.com/uni-stack/uniwind/blob/a2406b8e04f5597b32a44febe01159c5223ee3c6/packages/uniwind/types.d.ts.
Changelog:
[General][Changed] - Strict TypeScript API: Additional component props types are now
interfacedeclarations, enabling module augmentation by libraries like Uniwind (preserve compatibility)Differential Revision: D105028014