Skip to content

Codemod and sign a bunch of out of date files#676

Open
everettbu wants to merge 1 commit into
builds/facebook-fbsourcefrom
export-D95907848-to-builds/facebook-fbsource
Open

Codemod and sign a bunch of out of date files#676
everettbu wants to merge 1 commit into
builds/facebook-fbsourcefrom
export-D95907848-to-builds/facebook-fbsource

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35989
Original author: marcoww6


Summary: Those js1 files are out of sync. Codemod'ed and signed manually

Differential Revision: D95907848

Summary: Those js1 files are out of sync. Codemod'ed and signed manually

Differential Revision: D95907848
@greptile-apps

greptile-apps Bot commented Mar 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR is a codemod that modernizes Flow generic type constraint syntax in ReactNativeTypes.js, replacing the legacy colon-bound notation (<T: Bound>) with the newer extends keyword (<T extends Bound>), and updates the @generated SignedSource hash accordingly. It mirrors the upstream Facebook React change (react/react#35989).

  • Updates 5 occurrences of <TElementType: React.ElementType><TElementType extends React.ElementType> across InspectorDataGetter, ReactNativeType, and ReactFabricType.
  • No functional or behavioral type changes — this is purely a syntax modernization aligned with newer Flow versions and TypeScript-compatible style.
  • The @generated SignedSource hash on line 10 is correctly regenerated to reflect the updated file contents.

Confidence Score: 5/5

  • This PR is safe to merge — it is a purely syntactic codemod with no behavioral changes.
  • The change is a straightforward Flow syntax modernization with no logic alterations. All five type constraint substitutions are mechanically equivalent (<T: Bound> and <T extends Bound> are semantically identical in Flow). The signature hash update is correct and expected for a @generated file.
  • No files require special attention.

Important Files Changed

Filename Overview
compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js Updates generic type constraint syntax from Flow's old colon notation (<T: Bound>) to the newer extends keyword (<T extends Bound>) in 5 places across InspectorDataGetter, ReactNativeType, and ReactFabricType. The @generated SignedSource hash is correctly updated to match the new file contents.

Last reviewed commit: 8e0cb61

@greptile-apps-staging

Copy link
Copy Markdown

Greptile Summary

This PR applies a codemod to ReactNativeTypes.js (a compiled, @generated shim file) to update the generic type constraint syntax and refresh the SignedSource hash. The only substantive code change is replacing Flow-style bounded generics (<TElementType: React.ElementType>) with TypeScript-style bounded generics (<TElementType extends React.ElementType>) in five places.

Key concern:

  • The file retains the @flow strict pragma and is saturated with Flow-specific constructs ($ReadOnly<{...}>, $FlowFixMe, opaque type, mixed, ? nullable annotations). extends for generic bounds is TypeScript syntax; Flow exclusively uses : for the same purpose. Applying this change without removing the @flow strict annotation and converting the remaining Flow-specific syntax will cause flow check failures.

Other observations:

  • The SignedSource hash update is expected for a regenerated file.
  • No runtime behavior is affected — this is a type-definition shim only.

Confidence Score: 2/5

  • Not safe to merge as-is — the codemod introduces TypeScript generic-bound syntax into a file that is still governed by @flow strict, which will break Flow type checking.
  • The sole code change replaces Flow's : bounded-generic syntax with TypeScript's extends keyword across five method signatures, while the file remains annotated @flow strict and uses Flow-specific types ($ReadOnly, opaque type, mixed, ?, $FlowFixMe) everywhere else. This is a partial, inconsistent migration that will fail static type checking. Either the annotation and all Flow-specific syntax must be migrated, or the codemod changes must be reverted.
  • compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js

Important Files Changed

Filename Overview
compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeTypes.js Codemod changed generic bound syntax from Flow (:) to TypeScript (extends) in a file still annotated @flow strict with Flow-specific types throughout; this is invalid Flow syntax and will cause type-checking failures.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["ReactNativeTypes.js\n(@flow strict + @generated)"] --> B["Generic Bound Syntax\nBEFORE: &lt;TElementType: React.ElementType&gt;\nAFTER:  &lt;TElementType extends React.ElementType&gt;"]
    B --> C{File annotation?}
    C -->|"@flow strict still present"| D["Flow type-checker\n❌ 'extends' is invalid Flow syntax\nExpects ':' for bounded generics"]
    C -->|"If migrated to TypeScript"| E["TypeScript compiler\n✅ 'extends' is correct TS syntax"]
    D --> F["Flow check FAILS\nfor all 5 changed signatures"]
    E --> G["Remaining Flow types\n($ReadOnly, opaque type, mixed, ?)\nmust also be migrated"]
Loading

Last reviewed commit: 8e0cb61


type InspectorDataGetter = (
<TElementType: React.ElementType>(
<TElementType extends React.ElementType>(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid generic bound syntax for a @flow strict file

This file is annotated @flow strict (line 9) and uses Flow-specific constructs throughout ($ReadOnly, $FlowFixMe, opaque type, mixed, ? nullable types). Flow uses the : colon syntax for bounded generics — extends is TypeScript syntax. The codemod changed all five occurrences of <TElementType: React.ElementType> to <TElementType extends React.ElementType>, which is not valid Flow and will cause flow check to fail under strict mode.

The same pattern applies at lines 146, 149, 175, and 178. For example:

Suggested change
<TElementType extends React.ElementType>(
<TElementType: React.ElementType>(

All five occurrences would need to be reverted to : unless the file's @flow strict annotation is simultaneously removed and the remaining Flow-specific syntax ($ReadOnly, opaque type, etc.) is also migrated to TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants