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: react#57490 (comment) The DefinitelyTyped `react-native-web` types augment the `react-native` module to layer web-only props and style values onto React Native's types. Module augmentation only works against `interface` declarations, so these hit `error TS2300: Duplicate identifier`. This was solved in react#56809 — this diff extends `interface` emission to additional types as below. **Changes** Annotate the remaining types that `types/react-native-web` augments with `build-types emit-as-interface`: - `AccessibilityProps` - `ImageProps` - `PressableStateCallbackType` - `ViewStyle`, `TextStyle`, `ImageStyle` **Source for matched `types/react-native-web` conflicts** | Type | Declared in | Augmented by `types/react-native-web` | | --- | --- | --- | | `AccessibilityProps` | `Libraries/Components/View/ViewAccessibility.js:342` | [index.d.ts#L1272](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1272) | | `ImageProps` | `Libraries/Image/ImageProps.js:336` | [index.d.ts#L1422](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1422) | | `PressableStateCallbackType` | `Libraries/Components/Pressable/Pressable.js:36` | [index.d.ts#L1444](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1444) | | `ViewStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:141` | [index.d.ts#L1458](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1458) | | `TextStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:159` | [index.d.ts#L1486](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1486) | | `ImageStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:177` | [index.d.ts#L1514](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1514) | **Not fixed** The remaining DT failures (parsed from https://github.com/DefinitelyTyped/DefinitelyTyped/actions/runs/32138113480) aren't interface issues: - `InteractionManager` has no export in the Strict API at all. - `VirtualizedListProps` is genuinely non-generic in the Flow source (`packages/virtualized-lists/Lists/VirtualizedListProps.js:287`), and `getItem` / `getItemCount` are required there. DT's `VirtualizedListProps<ItemT>` with those omitted is an assumption carried over from the old hand-written types. - The `ViewStyle` / `TextStyle` / `ImageStyle` "incorrectly extends `WebStyle`" errors **will persist**. RN's `DimensionValue` includes `null`, and DT redefines `bottom?: CSSProperties["bottom"] | DimensionValue` on an interface extending `WebStyle`, whose `bottom` does not accept `null`. DT needs `Exclude<DimensionValue, null>` there. Expect 3 of the 16 reported errors to remain once the duplicate-identifier ones clear. cc rjbailey Changelog: [General][Fixed] - **JS API**: Additional Props/Style types are now defined as `interface`, fixing compatibility with certain DefinitelyTyped packages Pull Request resolved: react#58062 Test Plan: - `node ./scripts/js-api/build-types` — snapshot regenerated; `--validate` passes - `yarn test-generated-typescript`, `yarn test-typescript` — pass - `yarn jest scripts/js-api` — 141 tests pass - Scratch project replaying react-native-web's augmentations against `types_generated`: all six now merge cleanly. As a control, augmenting `ImagePropsAndroid` (still a type alias) in the same harness reproduces `error TS2300: Duplicate identifier`, confirming the harness detects the failure mode. Reviewed By: cipolleschi Differential Revision: D117534044 Pulled By: cortinico fbshipit-source-id: 8fc37375f7a3d9ea86e1a206059d365b38658231
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.