---
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/optional-member-expression.js
---
Input:
function Foo(props) {
  let x = bar(props.a);
  let y = x?.b;

  let z = useBar(y);
  return z;
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "FunctionDeclaration",
      "id": {
        "type": "Identifier",
        "name": "Foo",
        "typeAnnotation": null,
        "loc": null,
        "range": [
          9,
          12
        ]
      },
      "params": [
        {
          "type": "Identifier",
          "name": "props",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            13,
            18
          ]
        }
      ],
      "body": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "x",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    28,
                    29
                  ]
                },
                "init": {
                  "type": "CallExpression",
                  "callee": {
                    "type": "Identifier",
                    "name": "bar",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      32,
                      35
                    ]
                  },
                  "arguments": [
                    {
                      "type": "MemberExpression",
                      "object": {
                        "type": "Identifier",
                        "name": "props",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          36,
                          41
                        ]
                      },
                      "property": {
                        "type": "Identifier",
                        "name": "a",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          42,
                          43
                        ]
                      },
                      "computed": false,
                      "loc": null,
                      "range": [
                        36,
                        43
                      ]
                    }
                  ],
                  "loc": null,
                  "range": [
                    32,
                    44
                  ]
                },
                "loc": null,
                "range": [
                  28,
                  44
                ]
              }
            ],
            "loc": null,
            "range": [
              24,
              45
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "y",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    52,
                    53
                  ]
                },
                "init": {
                  "type": "OptionalMemberExpression",
                  "object": {
                    "type": "Identifier",
                    "name": "x",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      56,
                      57
                    ]
                  },
                  "property": {
                    "type": "Identifier",
                    "name": "b",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      59,
                      60
                    ]
                  },
                  "computed": false,
                  "optional": true,
                  "loc": null,
                  "range": [
                    56,
                    60
                  ]
                },
                "loc": null,
                "range": [
                  52,
                  60
                ]
              }
            ],
            "loc": null,
            "range": [
              48,
              61
            ]
          },
          {
            "type": "VariableDeclaration",
            "kind": "let",
            "declarations": [
              {
                "type": "VariableDeclarator",
                "id": {
                  "type": "Identifier",
                  "name": "z",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    69,
                    70
                  ]
                },
                "init": {
                  "type": "CallExpression",
                  "callee": {
                    "type": "Identifier",
                    "name": "useBar",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      73,
                      79
                    ]
                  },
                  "arguments": [
                    {
                      "type": "Identifier",
                      "name": "y",
                      "typeAnnotation": null,
                      "loc": null,
                      "range": [
                        80,
                        81
                      ]
                    }
                  ],
                  "loc": null,
                  "range": [
                    73,
                    82
                  ]
                },
                "loc": null,
                "range": [
                  69,
                  82
                ]
              }
            ],
            "loc": null,
            "range": [
              65,
              83
            ]
          },
          {
            "type": "ReturnStatement",
            "argument": {
              "type": "Identifier",
              "name": "z",
              "typeAnnotation": null,
              "loc": null,
              "range": [
                93,
                94
              ]
            },
            "loc": null,
            "range": [
              86,
              95
            ]
          }
        ],
        "loc": null,
        "range": [
          20,
          97
        ]
      },
      "generator": false,
      "async": false,
      "loc": null,
      "range": [
        0,
        97
      ],
      "loc": null,
      "range": [
        0,
        97
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    97
  ]
}
