-
Notifications
You must be signed in to change notification settings - Fork 46.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[compiler] Todo for fbt with multiple pronoun/plural #30437
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1137e75
[compiler] Todo for fbt with multiple pronoun/plural
mofeiZ 5991434
Update on "[compiler] Todo for fbt with multiple pronoun/plural"
mofeiZ cc80ec7
Update on "[compiler] Todo for fbt with multiple pronoun/plural"
mofeiZ 4e69352
Update on "[compiler] Todo for fbt with multiple pronoun/plural"
mofeiZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be tracked separately as fbt does not dedupe across enum/plural/pronouns