@samitouri / QOS-React-2 / commits / d5dee80933

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

Lauren Tan committed Apr 27, 2023 at 16:25 UTC d5dee809338c551a8ff2301eabdfc9e83609eb91
2 files changed +75
compiler/forget/src/__tests__/fixtures/compiler/error.lambda-with-fbt.expect.md new
+45
@@ -0,0 +1,45 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import { fbt } from "fbt";
6 +
7 +function Component() {
8 + const buttonLabel = () => {
9 + if (!someCondition) {
10 + return <fbt desc="My label">{"Purchase as a gift"}</fbt>;
11 + } else if (
12 + !iconOnly &&
13 + showPrice &&
14 + item?.current_gift_offer?.price?.formatted != null
15 + ) {
16 + return (
17 + <fbt desc="Gift button's label">
18 + {"Gift | "}
19 + <fbt:param name="price">
20 + {item?.current_gift_offer?.price?.formatted}
21 + </fbt:param>
22 + </fbt>
23 + );
24 + } else if (!iconOnly && !showPrice) {
25 + return <fbt desc="Gift button's label">{"Gift"}</fbt>;
26 + }
27 + };
28 +
29 + return (
30 + <View>
31 + <Button text={buttonLabel()} />
32 + </View>
33 + );
34 +}
35 +
36 +```
37 +
38 +
39 +## Error
40 +
41 +```
42 +Cannot read properties of null (reading 'end')
43 +```
44 +
45 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/error.lambda-with-fbt.js new
+30
@@ -0,0 +1,30 @@
1 +import { fbt } from "fbt";
2 +
3 +function Component() {
4 + const buttonLabel = () => {
5 + if (!someCondition) {
6 + return <fbt desc="My label">{"Purchase as a gift"}</fbt>;
7 + } else if (
8 + !iconOnly &&
9 + showPrice &&
10 + item?.current_gift_offer?.price?.formatted != null
11 + ) {
12 + return (
13 + <fbt desc="Gift button's label">
14 + {"Gift | "}
15 + <fbt:param name="price">
16 + {item?.current_gift_offer?.price?.formatted}
17 + </fbt:param>
18 + </fbt>
19 + );
20 + } else if (!iconOnly && !showPrice) {
21 + return <fbt desc="Gift button's label">{"Gift"}</fbt>;
22 + }
23 + };
24 +
25 + return (
26 + <View>
27 + <Button text={buttonLabel()} />
28 + </View>
29 + );
30 +}