---
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/fbt-template-string-same-scope.js
---
Input:
import fbt from "fbt";

export function Component(props) {
  let count = 0;
  if (props.items) {
    count = props.items.length;
  }
  return (
    <View>
      {fbt(
        `for ${fbt.param("count", count)} experiences`,
        `Label for the number of items`,
        { project: "public" }
      )}
    </View>
  );
}


Output:
{
  "type": "Program",
  "body": [
    {
      "type": "ImportDeclaration",
      "specifiers": [
        {
          "type": "ImportDefaultSpecifier",
          "local": {
            "type": "Identifier",
            "name": "fbt",
            "typeAnnotation": null,
            "loc": null,
            "range": [
              7,
              10
            ]
          },
          "loc": null,
          "range": [
            7,
            10
          ]
        }
      ],
      "source": {
        "type": "StringLiteral",
        "value": "fbt",
        "loc": null,
        "range": [
          16,
          21
        ]
      },
      "loc": null,
      "range": [
        0,
        22
      ]
    },
    {
      "type": "ExportNamedDeclaration",
      "declaration": {
        "type": "FunctionDeclaration",
        "id": {
          "type": "Identifier",
          "name": "Component",
          "typeAnnotation": null,
          "loc": null,
          "range": [
            40,
            49
          ]
        },
        "params": [
          {
            "type": "Identifier",
            "name": "props",
            "typeAnnotation": null,
            "loc": null,
            "range": [
              50,
              55
            ]
          }
        ],
        "body": {
          "type": "BlockStatement",
          "body": [
            {
              "type": "VariableDeclaration",
              "kind": "let",
              "declarations": [
                {
                  "type": "VariableDeclarator",
                  "id": {
                    "type": "Identifier",
                    "name": "count",
                    "typeAnnotation": null,
                    "loc": null,
                    "range": [
                      65,
                      70
                    ]
                  },
                  "init": {
                    "type": "NumericLiteral",
                    "value": 0.0,
                    "loc": null,
                    "range": [
                      73,
                      74
                    ]
                  },
                  "loc": null,
                  "range": [
                    65,
                    74
                  ]
                }
              ],
              "loc": null,
              "range": [
                61,
                75
              ]
            },
            {
              "type": "IfStatement",
              "test": {
                "type": "MemberExpression",
                "object": {
                  "type": "Identifier",
                  "name": "props",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    82,
                    87
                  ]
                },
                "property": {
                  "type": "Identifier",
                  "name": "items",
                  "typeAnnotation": null,
                  "loc": null,
                  "range": [
                    88,
                    93
                  ]
                },
                "computed": false,
                "loc": null,
                "range": [
                  82,
                  93
                ]
              },
              "consequent": {
                "type": "BlockStatement",
                "body": [
                  {
                    "type": "ExpressionStatement",
                    "expression": {
                      "type": "AssignmentExpression",
                      "operator": "=",
                      "left": {
                        "type": "Identifier",
                        "name": "count",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          101,
                          106
                        ]
                      },
                      "right": {
                        "type": "MemberExpression",
                        "object": {
                          "type": "MemberExpression",
                          "object": {
                            "type": "Identifier",
                            "name": "props",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              109,
                              114
                            ]
                          },
                          "property": {
                            "type": "Identifier",
                            "name": "items",
                            "typeAnnotation": null,
                            "loc": null,
                            "range": [
                              115,
                              120
                            ]
                          },
                          "computed": false,
                          "loc": null,
                          "range": [
                            109,
                            120
                          ]
                        },
                        "property": {
                          "type": "Identifier",
                          "name": "length",
                          "typeAnnotation": null,
                          "loc": null,
                          "range": [
                            121,
                            127
                          ]
                        },
                        "computed": false,
                        "loc": null,
                        "range": [
                          109,
                          127
                        ]
                      },
                      "loc": null,
                      "range": [
                        101,
                        127
                      ]
                    },
                    "directive": null,
                    "loc": null,
                    "range": [
                      101,
                      128
                    ]
                  }
                ],
                "loc": null,
                "range": [
                  95,
                  132
                ]
              },
              "alternate": null,
              "loc": null,
              "range": [
                78,
                132
              ]
            },
            {
              "type": "ReturnStatement",
              "argument": {
                "type": "JSXElement",
                "openingElement": {
                  "type": "JSXOpeningElement",
                  "name": {
                    "type": "JSXIdentifier",
                    "name": "View",
                    "loc": null,
                    "range": [
                      149,
                      153
                    ]
                  },
                  "attributes": [],
                  "selfClosing": false,
                  "loc": null,
                  "range": [
                    148,
                    154
                  ]
                },
                "children": [
                  {
                    "type": "JSXText",
                    "value": "\n      ",
                    "raw": "\n      ",
                    "loc": null,
                    "range": [
                      154,
                      161
                    ]
                  },
                  {
                    "type": "JSXExpressionContainer",
                    "expression": {
                      "type": "CallExpression",
                      "callee": {
                        "type": "Identifier",
                        "name": "fbt",
                        "typeAnnotation": null,
                        "loc": null,
                        "range": [
                          162,
                          165
                        ]
                      },
                      "arguments": [
                        {
                          "type": "TemplateLiteral",
                          "quasis": [
                            {
                              "type": "TemplateElement",
                              "tail": false,
                              "value": {
                                "cooked": "for ",
                                "raw": "for "
                              },
                              "loc": null,
                              "range": [
                                175,
                                182
                              ]
                            },
                            {
                              "type": "TemplateElement",
                              "tail": true,
                              "value": {
                                "cooked": " experiences",
                                "raw": " experiences"
                              },
                              "loc": null,
                              "range": [
                                207,
                                221
                              ]
                            }
                          ],
                          "expressions": [
                            {
                              "type": "CallExpression",
                              "callee": {
                                "type": "MemberExpression",
                                "object": {
                                  "type": "Identifier",
                                  "name": "fbt",
                                  "typeAnnotation": null,
                                  "loc": null,
                                  "range": [
                                    182,
                                    185
                                  ]
                                },
                                "property": {
                                  "type": "Identifier",
                                  "name": "param",
                                  "typeAnnotation": null,
                                  "loc": null,
                                  "range": [
                                    186,
                                    191
                                  ]
                                },
                                "computed": false,
                                "loc": null,
                                "range": [
                                  182,
                                  191
                                ]
                              },
                              "arguments": [
                                {
                                  "type": "StringLiteral",
                                  "value": "count",
                                  "loc": null,
                                  "range": [
                                    192,
                                    199
                                  ]
                                },
                                {
                                  "type": "Identifier",
                                  "name": "count",
                                  "typeAnnotation": null,
                                  "loc": null,
                                  "range": [
                                    201,
                                    206
                                  ]
                                }
                              ],
                              "loc": null,
                              "range": [
                                182,
                                207
                              ]
                            }
                          ],
                          "loc": null,
                          "range": [
                            175,
                            221
                          ]
                        },
                        {
                          "type": "TemplateLiteral",
                          "quasis": [
                            {
                              "type": "TemplateElement",
                              "tail": true,
                              "value": {
                                "cooked": "Label for the number of items",
                                "raw": "Label for the number of items"
                              },
                              "loc": null,
                              "range": [
                                231,
                                262
                              ]
                            }
                          ],
                          "expressions": [],
                          "loc": null,
                          "range": [
                            231,
                            262
                          ]
                        },
                        {
                          "type": "ObjectExpression",
                          "properties": [
                            {
                              "type": "Property",
                              "key": {
                                "type": "Identifier",
                                "name": "project",
                                "typeAnnotation": null,
                                "loc": null,
                                "range": [
                                  274,
                                  281
                                ]
                              },
                              "value": {
                                "type": "StringLiteral",
                                "value": "public",
                                "loc": null,
                                "range": [
                                  283,
                                  291
                                ]
                              },
                              "kind": "init",
                              "method": false,
                              "shorthand": false,
                              "computed": false,
                              "loc": null,
                              "range": [
                                274,
                                291
                              ]
                            }
                          ],
                          "loc": null,
                          "range": [
                            272,
                            293
                          ]
                        }
                      ],
                      "loc": null,
                      "range": [
                        162,
                        301
                      ]
                    },
                    "loc": null,
                    "range": [
                      161,
                      302
                    ]
                  },
                  {
                    "type": "JSXText",
                    "value": "\n    ",
                    "raw": "\n    ",
                    "loc": null,
                    "range": [
                      302,
                      307
                    ]
                  }
                ],
                "closingElement": {
                  "type": "JSXClosingElement",
                  "name": {
                    "type": "JSXIdentifier",
                    "name": "View",
                    "loc": null,
                    "range": [
                      309,
                      313
                    ]
                  },
                  "loc": null,
                  "range": [
                    307,
                    314
                  ]
                },
                "loc": null,
                "range": [
                  148,
                  314
                ]
              },
              "loc": null,
              "range": [
                135,
                319
              ]
            }
          ],
          "loc": null,
          "range": [
            57,
            321
          ]
        },
        "generator": false,
        "async": false,
        "loc": null,
        "range": [
          31,
          321
        ],
        "loc": null,
        "range": [
          31,
          321
        ]
      },
      "specifiers": [],
      "source": null,
      "loc": null,
      "range": [
        24,
        321
      ]
    }
  ],
  "sourceType": "script",
  "loc": null,
  "range": [
    0,
    321
  ]
}
