Fully replace hermes-(estree|parser|eslint|transform) packages with flow-* counterparts in react-native (#57851)

Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57851

The flow-* packages have support for all latest syntax and is better maintained.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D115064040

fbshipit-source-id: 7265eb722910a460c76d0dbde0603cf962fe4e4e
This commit is contained in:
Sam Zhou authored and meta-codesync[bot] committed 2026-08-10 07:21:52 -07:00
1 parent ad3755894f
commit 727e87ed26
27 files changed
+91 -101

No files matched your search

-2
View File
@@ -93,8 +93,6 @@
"flow-eslint": "0.325.0",
"flow-parser": "0.325.0",
"flow-transform": "0.325.0",
"hermes-eslint": "0.37.0",
"hermes-transform": "0.37.0",
"ini": "^5.0.0",
"inquirer": "^7.1.0",
"jest": "^29.7.0",
@@ -27,8 +27,7 @@
"devDependencies": {
"babel-plugin-syntax-hermes-parser": "0.37.0",
"flow-parser": "0.325.0",
"flow-eslint": "0.325.0",
"hermes-eslint": "0.37.0"
"flow-eslint": "0.325.0"
},
"engines": {
"node": "^22.13.0 || ^24.3.0 || >= 26.0.0"
+1 -2
View File
@@ -40,8 +40,7 @@
"source-map-support": "0.5.0"
},
"devDependencies": {
"flow-eslint": "0.325.0",
"hermes-eslint": "0.37.0"
"flow-eslint": "0.325.0"
},
"engines": {
"node": "^22.13.0 || ^24.3.0 || >= 26.0.0"
@@ -29,7 +29,6 @@
"@babel/core": "^7.25.2",
"@react-native/babel-preset": "0.87.0-main",
"flow-parser": "0.325.0",
"hermes-parser": "0.37.0",
"nullthrows": "^1.1.1"
},
"peerDependencies": {
@@ -32,7 +32,6 @@
"@babel/core": "^7.25.2",
"@babel/parser": "^7.29.0",
"flow-parser": "0.325.0",
"hermes-parser": "0.37.0",
"invariant": "^2.2.4",
"nullthrows": "^1.1.1",
"tinyglobby": "^0.2.15",
@@ -48,7 +47,6 @@
"@babel/preset-env": "^7.25.3",
"babel-plugin-syntax-hermes-parser": "0.37.0",
"flow-estree": "0.325.0",
"hermes-estree": "0.37.0",
"micromatch": "^4.0.4",
"prettier": "3.9.4",
"rimraf": "^3.0.2"
@@ -14,10 +14,12 @@ import FlatList, {type FlatListProps} from '../../Lists/FlatList';
import createAnimatedComponent from '../createAnimatedComponent';
import * as React from 'react';
export default createAnimatedComponent(FlatList) as $FlowFixMe as component<
const AnimatedFlatList: component<
// $FlowExpectedError[unclear-type]
ItemT = any,
>(
ref?: React.RefSetter<FlatList<ItemT>>,
...props: AnimatedProps<FlatListProps<ItemT>>
);
) = createAnimatedComponent(FlatList) as $FlowFixMe;
export default AnimatedFlatList;
@@ -15,7 +15,7 @@ import createAnimatedComponent from '../createAnimatedComponent';
import * as React from 'react';
// $FlowFixMe[incompatible-type]
export default createAnimatedComponent(SectionList) as $FlowFixMe as component<
const AnimatedSectionList: component<
// $FlowExpectedError[unclear-type]
ItemT = any,
// $FlowExpectedError[unclear-type]
@@ -23,4 +23,6 @@ export default createAnimatedComponent(SectionList) as $FlowFixMe as component<
>(
ref?: React.RefSetter<SectionList<ItemT, SectionT>>,
...props: AnimatedProps<SectionListProps<ItemT, SectionT>>
);
) = createAnimatedComponent(SectionList) as $FlowFixMe;
export default AnimatedSectionList;
@@ -370,10 +370,10 @@ function usePressState(forcePressed: boolean): [boolean, (boolean) => void] {
return [pressed || forcePressed, setPressed];
}
const MemoedPressable = memo(Pressable);
MemoedPressable.displayName = 'Pressable';
export default MemoedPressable as component(
const MemoedPressable: component(
ref?: React.RefSetter<PressableInstance>,
...props: PressableProps
);
) = memo(Pressable);
MemoedPressable.displayName = 'Pressable';
export default MemoedPressable;
+21 -18
View File
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<040a8eb579cea089295c7137db40e0d6>>
* @generated SignedSource<<4406ddb15814262a7ccc2b56e9625d67>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
@@ -22,11 +22,7 @@
/* eslint-disable redundant-undefined/redundant-undefined */
import * as React from "react"
declare const $$AnimatedFlatList: <ItemT = any>(
props: Omit<AnimatedProps<FlatListProps<ItemT>>, "ref"> & {
ref?: React.Ref<FlatList<ItemT>>
},
) => React.ReactNode
declare const $$AnimatedFlatList: typeof AnimatedFlatList_default
declare const $$AnimatedImage: AnimatedComponentType<
React.JSX.LibraryManagedAttributes<
typeof Image,
@@ -62,11 +58,7 @@ declare const $$AnimatedImplementation: {
ValueXY: typeof AnimatedValueXY_default
}
declare const $$AnimatedScrollView: typeof AnimatedScrollView_default
declare const $$AnimatedSectionList: <ItemT = any, SectionT = any>(
props: Omit<AnimatedProps<SectionListProps<ItemT, SectionT>>, "ref"> & {
ref?: React.Ref<SectionList<ItemT, SectionT>>
},
) => React.ReactNode
declare const $$AnimatedSectionList: typeof AnimatedSectionList_default
declare const $$AnimatedText: AnimatedComponentType<
TextProps,
React.ComponentRef<typeof Text>
@@ -145,10 +137,20 @@ declare const addImpl: (
a: AnimatedNode_default | number,
b: AnimatedNode_default | number,
) => AnimatedAddition_default
declare const AnimatedFlatList_default: <ItemT = any>(
props: Omit<AnimatedProps<FlatListProps<ItemT>>, "ref"> & {
ref?: React.Ref<FlatList<ItemT>>
},
) => React.ReactNode
declare const AnimatedScrollView_default: AnimatedComponentType<
ScrollViewProps,
AnimatedScrollViewInstance
>
declare const AnimatedSectionList_default: <ItemT = any, SectionT = any>(
props: Omit<AnimatedProps<SectionListProps<ItemT, SectionT>>, "ref"> & {
ref?: React.Ref<SectionList<ItemT, SectionT>>
},
) => React.ReactNode
declare const AppState: typeof AppState_default
declare const AppState_default: AppStateImpl
declare const AssetRegistry: {
@@ -269,6 +271,11 @@ declare const loopImpl: (
animation: CompositeAnimation,
$$PARAM_1$$?: LoopAnimationConfig,
) => CompositeAnimation
declare const MemoedPressable_default: (
props: PressableProps & {
ref?: React.Ref<PressableInstance>
},
) => React.ReactNode
declare const Modal: typeof Wrapper_default
declare const modulo: typeof $$AnimatedImplementation.modulo
declare const moduloImpl: (
@@ -311,11 +318,7 @@ declare const Presets: {
linear: LayoutAnimationConfig
spring: LayoutAnimationConfig
}
declare const Pressable: (
props: PressableProps & {
ref?: React.Ref<PressableInstance>
},
) => React.ReactNode
declare const Pressable: typeof MemoedPressable_default
declare const processColor: typeof processColor_default
declare const ProgressBarAndroid: typeof ProgressBarAndroid_default
declare let ProgressBarAndroid_default: (
@@ -5722,7 +5725,7 @@ export {
AlertOptions, // 8a116d2a
AlertType, // 5ab91217
AndroidKeyboardEvent, // e03becc8
Animated, // 4bf77b70
Animated, // d74ec583
AppConfig, // 35c0ca70
AppRegistry, // 1e8c5a00
AppState, // 12012be5
@@ -5881,7 +5884,7 @@ export {
PointerEvent, // ff599afe
PressabilityConfig, // fea539a5
PressabilityEventHandlers, // c222648b
Pressable, // 7008c06f
Pressable, // ed5391ac
PressableAndroidRippleConfig, // ee32eaca
PressableInstance, // eebfe911
PressableProps, // d6bfa55b
@@ -26,18 +26,15 @@ component VirtualColumnLayout(
);
}
const VirtualColumn = createVirtualCollectionView(
VirtualColumnLayout,
VirtualColumnGenerator,
);
// TODO: Figure out component generic resolution.
// @see https://fb.workplace.com/groups/flow/posts/29355518614070041
// export default VirtualColumn as VirtualCollectionViewComponent<VirtualColumnLayoutProps>;
export default VirtualColumn as component<out TItem extends Item>(
// const VirtualColumn: VirtualCollectionViewComponent<VirtualColumnLayoutProps> = ...
const VirtualColumn: component<out TItem extends Item>(
children: (item: TItem, key: string) => React.Node,
items: VirtualCollection<TItem>,
itemToKey?: (TItem) => string,
removeClippedSubviews?: boolean,
testID?: ?string,
);
) = createVirtualCollectionView(VirtualColumnLayout, VirtualColumnGenerator);
export default VirtualColumn;
@@ -26,18 +26,15 @@ component VirtualRowLayout(
);
}
const VirtualRow = createVirtualCollectionView(
VirtualRowLayout,
VirtualRowGenerator,
);
// TODO: Figure out component generic resolution.
// @see https://fb.workplace.com/groups/flow/posts/29355518614070041
// export default VirtualRow as VirtualCollectionViewComponent<VirtualRowLayoutProps>;
export default VirtualRow as component<out TItem extends Item>(
// const VirtualRow: VirtualCollectionViewComponent<VirtualRowLayoutProps> = ...
const VirtualRow: component<out TItem extends Item>(
children: (item: TItem, key: string) => React.Node,
items: VirtualCollection<TItem>,
itemToKey?: (TItem) => string,
removeClippedSubviews?: boolean,
testID?: ?string,
);
) = createVirtualCollectionView(VirtualRowLayout, VirtualRowGenerator);
export default VirtualRow;
@@ -9,12 +9,12 @@
*/
import type {DependencyContext} from './simpleResolve';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
const resolveTypeInputFile = require('./resolveTypeInputFile');
const simpleResolve = require('./simpleResolve');
const debug = require('debug')('build-types:resolution');
const {traverse} = require('hermes-transform/dist/traverse/traverse');
const {traverse} = require('flow-transform/dist/traverse/traverse');
const reportedUnresolvedDeps = new Set<string>();
@@ -9,7 +9,7 @@
*/
const ensureNoUnprefixedProps = require('../ensureNoUnprefixedProps');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const reattachDocComments = require('../reattachDocComments');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const replaceEmptyWithNever = require('../replaceEmptyWithNever');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const replaceNullablePropertiesWithUndefined = require('../replaceNullablePropertiesWithUndefined');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const replaceRequiresWithImports = require('../replaceRequiresWithImports');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const replaceStringishWithString = require('../replaceStringishWithString');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -9,7 +9,7 @@
*/
const stripPrivateProperties = require('../stripPrivateProperties');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
const prettierOptions = {parser: 'babel'};
@@ -8,11 +8,11 @@
* @format
*/
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
const visitors: TransformVisitor = context => ({
TypeAlias(node): void {
@@ -14,12 +14,12 @@ import type {
ModuleDeclaration,
Program,
Statement,
} from 'hermes-estree/dist';
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
} from 'flow-estree/dist';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
type BodyNode = Statement | ModuleDeclaration;
@@ -177,15 +177,11 @@ function findDeclarationByName(
return {statement, kind: declaration.type};
}
// `declare const X` in `.js.flow` declaration files
// `DeclareVariable` is `declare const X` in `.js.flow` declaration files
if (
declaration.type === 'DeclareVariable' &&
declaration.id.name === name
declaration.type === 'VariableDeclaration' ||
declaration.type === 'DeclareVariable'
) {
return {statement, kind: declaration.type};
}
if (declaration.type === 'VariableDeclaration') {
for (const declarator of declaration.declarations) {
if (
declarator.id.type === 'Identifier' &&
@@ -8,11 +8,11 @@
* @format
*/
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
const visitors: TransformVisitor = context => ({
EmptyTypeAnnotation(node): void {
@@ -8,12 +8,12 @@
* @format
*/
import type {ESNode, TypeAnnotationType} from 'hermes-estree';
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {ESNode, TypeAnnotationType} from 'flow-estree';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
function isInsideObjectTypeProperty(node: TypeAnnotationType) {
let current: ESNode = node;
@@ -8,11 +8,11 @@
* @format
*/
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
const visitors: TransformVisitor = context => ({
VariableDeclaration(node): void {
@@ -8,11 +8,11 @@
* @format
*/
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
const visitors: TransformVisitor = context => ({
GenericTypeAnnotation(node): void {
@@ -8,11 +8,11 @@
* @format
*/
import type {TransformVisitor} from 'hermes-transform';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {TransformVisitor} from 'flow-transform';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const {transformAST} = require('hermes-transform/dist/transform/transformAST');
const {transformAST} = require('flow-transform/dist/transform/transformAST');
const visitors: TransformVisitor = context => ({
ObjectTypeProperty(node): void {
@@ -9,13 +9,13 @@
*/
import type {PluginObj} from '@babel/core';
import type {ParseResult} from 'hermes-transform/dist/transform/parse';
import type {TransformASTResult} from 'hermes-transform/dist/transform/transformAST';
import type {ParseResult} from 'flow-transform/dist/transform/parse';
import type {TransformASTResult} from 'flow-transform/dist/transform/transformAST';
const getDependencies = require('./resolution/getDependencies');
const applyBabelTransformsSeq = require('./utils/applyBabelTransformsSeq');
const translate = require('flow-api-translator');
const {parse, print} = require('hermes-transform');
const {parse, print} = require('flow-transform');
type PreTransformFn = ParseResult => Promise<TransformASTResult>;