Skip to content

Commit 37c6ea8

Browse files
committed
[compiler] Typedefs for Array.prototype.flatMap
ghstack-source-id: af4c7ac Pull Request resolved: #30794
1 parent 039c5c0 commit 37c6ea8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

compiler/packages/babel-plugin-react-compiler/src/HIR/ObjectShape.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,23 @@ addObject(BUILTIN_SHAPES, BuiltInArrayId, [
317317
mutableOnlyIfOperandsAreMutable: true,
318318
}),
319319
],
320+
[
321+
'flatMap',
322+
addFunction(BUILTIN_SHAPES, [], {
323+
positionalParams: [],
324+
restParam: Effect.ConditionallyMutate,
325+
returnType: {kind: 'Object', shapeId: BuiltInArrayId},
326+
/*
327+
* callee is ConditionallyMutate because items of the array
328+
* flow into the lambda and may be mutated there, even though
329+
* the array object itself is not modified
330+
*/
331+
calleeEffect: Effect.ConditionallyMutate,
332+
returnValueKind: ValueKind.Mutable,
333+
noAlias: true,
334+
mutableOnlyIfOperandsAreMutable: true,
335+
}),
336+
],
320337
[
321338
'filter',
322339
addFunction(BUILTIN_SHAPES, [], {
@@ -534,6 +551,17 @@ addObject(BUILTIN_SHAPES, BuiltInMixedReadonlyId, [
534551
noAlias: true,
535552
}),
536553
],
554+
[
555+
'flatMap',
556+
addFunction(BUILTIN_SHAPES, [], {
557+
positionalParams: [],
558+
restParam: Effect.Read,
559+
returnType: {kind: 'Object', shapeId: BuiltInArrayId},
560+
calleeEffect: Effect.ConditionallyMutate,
561+
returnValueKind: ValueKind.Mutable,
562+
noAlias: true,
563+
}),
564+
],
537565
[
538566
'filter',
539567
addFunction(BUILTIN_SHAPES, [], {

0 commit comments

Comments
 (0)