From 827dca79fe9fc8d8eee6261a7a2d376d7a663708 Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Thu, 9 Jul 2026 06:59:34 -0700 Subject: [PATCH] Flow: Fix `@babel/types` libdef for `getBindingIdentifiers` Summary: X-link: https://github.com/react/react-native/pull/57488 The generated Flow libdef for `babel/types` declared `duplicates` as a required parameter on `getBindingIdentifiers` and `getOuterBindingIdentifiers`. It is actually optional, both at runtime (only read as a truthy flag, defaulting to the non-duplicate map) and in the upstream TS types: https://github.com/babel/babel/blob/7.x/packages/babel-types/src/retrievers/getBindingIdentifiers.ts#L17-L36 This prevented legitimate single-argument use later in this stack. Separating it for export to RN + Metro. Changelog: [Internal] Reviewed By: GijsWeterings Differential Revision: D111056985 --- flow-typed/npm/babel-types_v7.x.x.js | 4 ++-- scripts/support/generateBabelTypesFlowLibraryDefinition.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flow-typed/npm/babel-types_v7.x.x.js b/flow-typed/npm/babel-types_v7.x.x.js index 00aaa15964..c6b6cd7e64 100644 --- a/flow-typed/npm/babel-types_v7.x.x.js +++ b/flow-typed/npm/babel-types_v7.x.x.js @@ -3848,8 +3848,8 @@ declare module "@babel/types" { declare export function prependToMemberExpression(member: BabelNodeMemberExpression, prepend: BabelNodeExpression): BabelNodeMemberExpression declare export function removeProperties(n: T, opts: ?{}): void; declare export function removePropertiesDeep(n: T, opts: ?{}): T; - declare export function getBindingIdentifiers(node: BabelNode, duplicates: boolean, outerOnly?: boolean): { [key: string]: BabelNodeIdentifier | Array } - declare export function getOuterBindingIdentifiers(node: Node, duplicates: boolean): { [key: string]: BabelNodeIdentifier | Array } + declare export function getBindingIdentifiers(node: BabelNode, duplicates?: boolean, outerOnly?: boolean): { [key: string]: BabelNodeIdentifier | Array } + declare export function getOuterBindingIdentifiers(node: Node, duplicates?: boolean): { [key: string]: BabelNodeIdentifier | Array } declare export type TraversalAncestors = Array<{ node: BabelNode, key: string, diff --git a/scripts/support/generateBabelTypesFlowLibraryDefinition.js b/scripts/support/generateBabelTypesFlowLibraryDefinition.js index 6bdab43ef8..48164b69ad 100644 --- a/scripts/support/generateBabelTypesFlowLibraryDefinition.js +++ b/scripts/support/generateBabelTypesFlowLibraryDefinition.js @@ -221,9 +221,9 @@ function main() { // retrievers/ // eslint-disable-next-line max-len - `declare export function getBindingIdentifiers(node: ${NODE_PREFIX}, duplicates: boolean, outerOnly?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`, + `declare export function getBindingIdentifiers(node: ${NODE_PREFIX}, duplicates?: boolean, outerOnly?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`, // eslint-disable-next-line max-len - `declare export function getOuterBindingIdentifiers(node: Node, duplicates: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`, + `declare export function getOuterBindingIdentifiers(node: Node, duplicates?: boolean): { [key: string]: ${NODE_PREFIX}Identifier | Array<${NODE_PREFIX}Identifier> }`, // traverse/ `declare export type TraversalAncestors = Array<{