diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts index 9554878578ca0..04f85e496453a 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts @@ -317,6 +317,23 @@ addObject(BUILTIN_SHAPES, BuiltInArrayId, [ mutableOnlyIfOperandsAreMutable: true, }), ], + [ + 'flatMap', + addFunction(BUILTIN_SHAPES, [], { + positionalParams: [], + restParam: Effect.ConditionallyMutate, + returnType: {kind: 'Object', shapeId: BuiltInArrayId}, + /* + * callee is ConditionallyMutate because items of the array + * flow into the lambda and may be mutated there, even though + * the array object itself is not modified + */ + calleeEffect: Effect.ConditionallyMutate, + returnValueKind: ValueKind.Mutable, + noAlias: true, + mutableOnlyIfOperandsAreMutable: true, + }), + ], [ 'filter', addFunction(BUILTIN_SHAPES, [], { @@ -534,6 +551,17 @@ addObject(BUILTIN_SHAPES, BuiltInMixedReadonlyId, [ noAlias: true, }), ], + [ + 'flatMap', + addFunction(BUILTIN_SHAPES, [], { + positionalParams: [], + restParam: Effect.Read, + returnType: {kind: 'Object', shapeId: BuiltInArrayId}, + calleeEffect: Effect.ConditionallyMutate, + returnValueKind: ValueKind.Mutable, + noAlias: true, + }), + ], [ 'filter', addFunction(BUILTIN_SHAPES, [], {