-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] Todo for fbt with multiple pronoun/plural
ghstack-source-id: 2be0fa3784b9a7623118520deef07d669d975665 Pull Request resolved: #30437
- Loading branch information
Showing
7 changed files
with
129 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
...-compiler/src/__tests__/fixtures/compiler/fbt/bug-multiple-fbt-plural.expect.md
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...er/src/__tests__/fixtures/compiler/fbt/error.todo-multiple-fbt-plural.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
import fbt from 'fbt'; | ||
|
||
/** | ||
* Forget + fbt inconsistency. Evaluator errors with the following | ||
* Found differences in evaluator results | ||
* Non-forget (expected): | ||
* (kind: ok) 1 rewrite to Rust · 2 months traveling | ||
* Forget: | ||
* (kind: ok) 1 rewrites to Rust · 2 months traveling | ||
* | ||
* The root issue here is that fbt:plural/enum/pronoun read `.start` and `.end` from | ||
* babel nodes to slice into source strings for some complex dedupe logic | ||
* (see [_getStringVariationCombinations](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/JSFbtBuilder.js#L297)) | ||
* | ||
* | ||
* Since Forget does not add `.start` and `.end` for babel nodes it synthesizes, | ||
* [getRawSource](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/FbtUtil.js#L666-L673) | ||
* simply returns the whole source code string. As a result, all fbt nodes dedupe together | ||
* and _getStringVariationCombinations ends up early exiting (before adding valid candidate values). | ||
* | ||
* | ||
* | ||
* For fbt:plural tags specifically, the `count` node require that a `.start/.end` | ||
* (see [code in FbtPluralNode](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtPluralNode.js#L87-L90)) | ||
*/ | ||
function Foo({rewrites, months}) { | ||
return ( | ||
<fbt desc="Test fbt description"> | ||
<fbt:plural count={rewrites} name="number of rewrites" showCount="yes"> | ||
rewrite | ||
</fbt:plural> | ||
to Rust · | ||
<fbt:plural count={months} name="number of months" showCount="yes"> | ||
month | ||
</fbt:plural> | ||
traveling | ||
</fbt> | ||
); | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Foo, | ||
params: [{rewrites: 1, months: 2}], | ||
}; | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
31 | </fbt:plural> | ||
32 | to Rust · | ||
> 33 | <fbt:plural count={months} name="number of months" showCount="yes"> | ||
| ^^^^^^^^^^ Todo: Support <fbt> tags with multiple <fbt:plural> values (33:33) | ||
34 | month | ||
35 | </fbt:plural> | ||
36 | traveling | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters