---
source: crates/react_hermes_parser/tests/parser_test.rs
expression: "format!(\"Input:\\n{input}\\n\\nOutput:\\n{output}\")"
input_file: crates/react_hermes_parser/tests/fixtures/reduce-reactive-dependencies-optional-member-expression.js
---
Input:
function Component(props) {
  const x = [];
  x.push(props.items?.length);
  x.push(props.items?.edges?.map?.(render)?.filter?.(Boolean) ?? []);
  return x;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Component",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          9,
          18
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "props",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            19,
            24
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "const",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    36,
                    37
                  ]
                },
                "init": {
                  "type": "ArrayExpression",
                  "elements": [],
                  "loc": null,
                  "range": [
                    40,
                    42
                  ]
                },
                "loc": null,
                "range": [
                  36,
                  42
                ]
              }
            ],
            "loc": null,
            "range": [
              30,
              43
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "CallExpression",
              "callee": {
                "type": "MemberExpression",
                "object": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    46,
                    47
                  ]
                },
                "property": {
                  "type": "Identifier",
                  "name": "push",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    48,
                    52
                  ]
                },
                "computed": false,
                "loc": null,
                "range": [
                  46,
                  52
                ]
              },
              "arguments": [
                {
                  "type": "OptionalMemberExpression",
                  "object": {
                    "type": "MemberExpression",
                    "object": {
                      "type": "Identifier",
                      "name": "props",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        53,
                        58
                      ]
                    },
                    "property": {
                      "type": "Identifier",
                      "name": "items",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        59,
                        64
                      ]
                    },
                    "computed": false,
                    "loc": null,
                    "range": [
                      53,
                      64
                    ]
                  },
                  "property": {
                    "type": "Identifier",
                    "name": "length",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      66,
                      72
                    ]
                  },
                  "computed": false,
                  "optional": true,
                  "loc": null,
                  "range": [
                    53,
                    72
                  ]
                }
              ],
              "loc": null,
              "range": [
                46,
                73
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              46,
              74
            ]
          },
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "CallExpression",
              "callee": {
                "type": "MemberExpression",
                "object": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    77,
                    78
                  ]
                },
                "property": {
                  "type": "Identifier",
                  "name": "push",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    79,
                    83
                  ]
                },
                "computed": false,
                "loc": null,
                "range": [
                  77,
                  83
                ]
              },
              "arguments": [
                {
                  "type": "LogicalExpression",
                  "operator": "??",
                  "left": {
                    "type": "OptionalCallExpression",
                    "callee": {
                      "type": "OptionalMemberExpression",
                      "object": {
                        "type": "OptionalCallExpression",
                        "callee": {
                          "type": "OptionalMemberExpression",
                          "object": {
                            "type": "OptionalMemberExpression",
                            "object": {
                              "type": "MemberExpression",
                              "object": {
                                "type": "Identifier",
                                "name": "props",
                                "typeAnnotation": null,
                                "loc": null,
                                "range": [
                                  84,
                                  89
                                ]
                              },
                              "property": {
                                "type": "Identifier",
                                "name": "items",
                                "typeAnnotation": null,
                                "loc": null,
                                "range": [
                                  90,
                                  95
                                ]
                              },
                              "computed": false,
                              "loc": null,
                              "range": [
                                84,
                                95
                              ]
                            },
                            "property": {
                              "type": "Identifier",
                              "name": "edges",
                              "typeAnnotation": null,
                              "loc": null,
                              "range": [
                                97,
                                102
                              ]
                            },
                            "computed": false,
                            "optional": true,
                            "loc": null,
                            "range": [
                              84,
                              102
                            ]
                          },
                          "property": {
                            "type": "Identifier",
                            "name": "map",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              104,
                              107
                            ]
                          },
                          "computed": false,
                          "optional": true,
                          "loc": null,
                          "range": [
                            84,
                            107
                          ]
                        },
                        "arguments": [
                          {
                            "type": "Identifier",
                            "name": "render",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              110,
                              116
                            ]
                          }
                        ],
                        "optional": true,
                        "loc": null,
                        "range": [
                          84,
                          117
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "filter",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          119,
                          125
                        ]
                      },
                      "computed": false,
                      "optional": true,
                      "loc": null,
                      "range": [
                        84,
                        125
                      ]
                    },
                    "arguments": [
                      {
                        "type": "Identifier",
                        "name": "Boolean",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          128,
                          135
                        ]
                      }
                    ],
                    "optional": true,
                    "loc": null,
                    "range": [
                      84,
                      136
                    ]
                  },
                  "right": {
                    "type": "ArrayExpression",
                    "elements": [],
                    "loc": null,
                    "range": [
                      140,
                      142
                    ]
                  },
                  "loc": null,
                  "range": [
                    84,
                    142
                  ]
                }
              ],
              "loc": null,
              "range": [
                77,
                143
              ]
            },
            "directive": null,
            "loc": null,
            "range": [
              77,
              144
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "x",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                154,
                155
              ]
            },
            "loc": null,
            "range": [
              147,
              156
            ]
          }
        ],
        "loc": null,
        "range": [
          26,
          158
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        158
      ],
      "loc": null,
      "range": [
        0,
        158
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    158
  ]
}
