Convert additional Props/Style types to interface - #58062
Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
c359385 to
57b788f
Compare
|
Do you have any timeline for when you think this (or a similar PR) might be merged and released? The types break is blocking PRs to any react types on DT. |
|
@jakebailey As soon as this gets merged, I'll raise a pick request into the 0.87 branch, then it'll go out in the next patch release (typically Mondays). cc @zeyap @cortinico |
|
@huntie can you fix the conflicts with main? |
57b788f to
bb0b6be
Compare
|
@cortinico Done |
|
@cortinico has imported this pull request. If you are a Meta employee, you can view this in D117534044. |
|
@cortinico merged this pull request in 593ae02. |
@huntie I'm not sure that this happened; were you still working on the other breaks? I see #58168 now, but still hoping to get DT unbroken... |
|
@jakebailey Yes, opened here: reactwg/react-native-releases#1399. Waiting on the Release Crew to deploy this in the next patch. |
Summary
In response to this comment: #57490 (comment)
The DefinitelyTyped
react-native-webtypes augment thereact-nativemodule to layer web-only props and style values onto React Native's types. Module augmentation only works againstinterfacedeclarations, so these hiterror TS2300: Duplicate identifier.This was solved in #56809 — this diff extends
interfaceemission to additional types as below.Changes
Annotate the remaining types that
@types/react-native-webaugments with@build-types emit-as-interface:AccessibilityPropsImagePropsPressableStateCallbackTypeViewStyle,TextStyle,ImageStyleSource for matched
@types/react-native-webconflicts@types/react-native-webAccessibilityPropsLibraries/Components/View/ViewAccessibility.js:342ImagePropsLibraries/Image/ImageProps.js:336PressableStateCallbackTypeLibraries/Components/Pressable/Pressable.js:36ViewStyleLibraries/StyleSheet/StyleSheet.js.flow:141TextStyleLibraries/StyleSheet/StyleSheet.js.flow:159ImageStyleLibraries/StyleSheet/StyleSheet.js.flow:177Not fixed
The remaining DT failures (parsed from https://github.com/DefinitelyTyped/DefinitelyTyped/actions/runs/32138113480) aren't interface issues:
InteractionManagerhas no export in the Strict API at all.VirtualizedListPropsis genuinely non-generic in the Flow source (packages/virtualized-lists/Lists/VirtualizedListProps.js:287), andgetItem/getItemCountare required there. DT'sVirtualizedListProps<ItemT>with those omitted is an assumption carried over from the old hand-written types.ViewStyle/TextStyle/ImageStyle"incorrectly extendsWebStyle" errors will persist. RN'sDimensionValueincludesnull, and DT redefinesbottom?: CSSProperties["bottom"] | DimensionValueon an interface extendingWebStyle, whosebottomdoes not acceptnull. DT needsExclude<DimensionValue, null>there. Expect 3 of the 16 reported errors to remain once the duplicate-identifier ones clear.cc @jakebailey
Changelog:
[General][Fixed] - JS API: Additional Props/Style types are now defined as
interface, fixing compatibility with certain DefinitelyTyped packagesTest Plan
node ./scripts/js-api/build-types— snapshot regenerated;--validatepassesyarn test-generated-typescript,yarn test-typescript— passyarn jest scripts/js-api— 141 tests passtypes_generated: all six now merge cleanly. As a control, augmentingImagePropsAndroid(still a type alias) in the same harness reproduceserror TS2300: Duplicate identifier, confirming the harness detects the failure mode.