Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
db50e6b to
39ab067
Compare
|
@christophpurrer has imported this pull request. If you are a Meta employee, you can view this in D117876097. |
|
@huntie @cortinico Do we have update on this PR review (and #58062)? Until then, a project with react-native-web and TS cannot really update to RN 0.87+ |
I believe that #58062 has landed no? |
|
@cortinico I don't think so, as reactwg/react-native-releases#1399 is still open and I see no trace of it in the changelogs. Also, with it alone (without this PR), EDIT: I confirm that it has landed in 0.88 latest RC, but that it doesn't fix everything and that this PR is still needed.
|
|
@zoontek can you rebase and fix the conflict please? |
Review feedback from @zoontek. Two of the removed members are ones where the overlay was genuinely wider than React Native, rather than merely conflicting with it: - `position`, where React Native has 'absolute' | 'relative' | 'static' and the overlay added 'fixed' and 'sticky'. - `cursor`, where React Native has CursorValue, 'auto' | 'pointer', against a much larger web set. Both should come back once react/react-native#58168 makes the generated style types augmentable, so leave them commented out with a TODO rather than dropping them silently. The other removals stay deletions, because React Native's own declaration is already the wider one: `backgroundImage`, `backgroundSize`, `backgroundPosition` and `backgroundRepeat` accept `ReadonlyArray<…> | string` against the overlay's `string`, `boxShadow` and `filter` likewise, and `outlineColor` is `____ColorValue_Internal`, which is `null | string | number | NativeColorValue`. Restoring any of those would narrow the type again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Revert convertTypeAliasesToInterfaces to its original form. Get the same emitted types from the Flow sources instead. Styles: rename ____ViewStyle_Internal, ____TextStyle_Internal and ____ImageStyle_Internal to ViewStyle, TextStyle and ImageStyle. StyleSheet now re-exports each name unchanged, with no alias. Props: 11 annotated types still emitted members in the interface body. Each one now moves its inline members into a private <Name>Core alias. All members are inherited through the extends clause, so a module augmentation can refine them. ImagePropsBase and ImageBackgroundProps declare members that shadow keys of the type they spread. An explicit Omit removes those keys, because a Flow spread of an optional property unions the two types instead of replacing the member. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
25739b4 to
2eec85c
Compare
|
@cortinico done ✅ |
|
@cortinico merged this pull request in 447ccd1. |

Summary:
react-native-web and Nativewind extend React Native's types with module augmentation. #58062 made the props and style types interfaces, which cleared the duplicate identifier errors. Two things still can't be extended.
Styles:
ViewStyleis an interface derived from____ViewStyle_Internal, butViewProps['style']reads the base, so augmentingViewStyledoesn't reach it:____ViewStyle_Internalis now namedViewStyle, and the same for Text and Image.StyleSheetre-exports each name unchanged, so the interface and the base are one symbol.Props written as inline object literals: The transform copies them into the interface body, where a second declaration is a merge conflict rather than an override, so the augmentation is silently ignored. Eleven of the 24 annotated types are affected. Each now moves its inline members into a private
<Name>Corealias, so they reach the interface through the extends clause and are inherited, like everything fromViewPropsalready was:That costs 11 new names in the API snapshot, one per affected type.
PressablePropsset the precedent withPressableBaseProps.ImagePropsBaseandImageBackgroundPropsdeclare members that shadow keys of the type they spread, and a Flow spread of an optional property unions the two types instead of replacing the member, so those keys get an explicitOmit.Caveat: an augmented member has to be assignable to the inherited one. Adding a key is clean and narrowing works, but widening raises
TS2430on the declaration file, whichskipLibCheck: truesilences.Changelog:
[GENERAL] [CHANGED] - Allow module augmentation to extend generated props and style types
Test Plan:
yarn build-types: all 24 annotated types now emit an empty interface body.ViewStyle,TextStyleandImageStyleare unchanged; the props types gain the 11<Name>Corealiases.Compiled augmentations with
skipLibCheck: false. Styles: the two lines above pass here and reportTS2353onmain. Props: adding a key and narrowing an existing one on each of the 11 types passes here and reportsTS2717onmain.yarn flow-check,yarn test-generated-typescript,yarn format-checkandyarn lint: clean, apart from 3 Flow errors inpackages/react-native-codegen/libalready onmain.yarn jest packages/react-native/Libraries packages/react-native/src scripts/js-api: 632 tests pass, no snapshot changed.