Failing test for fbt issue

Specifically, the fbt plugin would error on a `null` loc as it [relies on it in 
one of its 
utils](https://github.com/facebook/fbt/blob/6a23a5374a757a49654d8304a3efea8eb9548eea/packages/babel-plugin-fbt/src/getNamespacedArgs.js#L82-L84), 
implying a missing `loc` somewhere in our pipeline after codegen
This commit is contained in:
Lauren Tan
2023-04-27 16:25:41 -04:00
parent 3eed52b49b
commit d5dee80933
2 changed files with 75 additions and 0 deletions
@@ -0,0 +1,45 @@
## Input
```javascript
import { fbt } from "fbt";
function Component() {
const buttonLabel = () => {
if (!someCondition) {
return <fbt desc="My label">{"Purchase as a gift"}</fbt>;
} else if (
!iconOnly &&
showPrice &&
item?.current_gift_offer?.price?.formatted != null
) {
return (
<fbt desc="Gift button's label">
{"Gift | "}
<fbt:param name="price">
{item?.current_gift_offer?.price?.formatted}
</fbt:param>
</fbt>
);
} else if (!iconOnly && !showPrice) {
return <fbt desc="Gift button's label">{"Gift"}</fbt>;
}
};
return (
<View>
<Button text={buttonLabel()} />
</View>
);
}
```
## Error
```
Cannot read properties of null (reading 'end')
```
@@ -0,0 +1,30 @@
import { fbt } from "fbt";
function Component() {
const buttonLabel = () => {
if (!someCondition) {
return <fbt desc="My label">{"Purchase as a gift"}</fbt>;
} else if (
!iconOnly &&
showPrice &&
item?.current_gift_offer?.price?.formatted != null
) {
return (
<fbt desc="Gift button's label">
{"Gift | "}
<fbt:param name="price">
{item?.current_gift_offer?.price?.formatted}
</fbt:param>
</fbt>
);
} else if (!iconOnly && !showPrice) {
return <fbt desc="Gift button's label">{"Gift"}</fbt>;
}
};
return (
<View>
<Button text={buttonLabel()} />
</View>
);
}