-
Notifications
You must be signed in to change notification settings - Fork 386
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
feat(macro): support JSX macro inside conditional expressions #1436
feat(macro): support JSX macro inside conditional expressions #1436
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
b34528b
to
dad400c
Compare
dad400c
to
2555690
Compare
Codecov ReportBase: 70.92% // Head: 71.02% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## next #1436 +/- ##
==========================================
+ Coverage 70.92% 71.02% +0.09%
==========================================
Files 75 75
Lines 1940 1943 +3
Branches 525 526 +1
==========================================
+ Hits 1376 1380 +4
+ Misses 452 451 -1
Partials 112 112
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
2555690
to
fbdcc68
Compare
fbdcc68
to
69c9278
Compare
;<Trans | ||
id={"Hello, {0}"} | ||
values={{ | ||
0: props.world ? <Trans id={'world'} /> : <Trans id={'guys'} /> | ||
}} | ||
/> |
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.
I'm thinking that we can automatically generate from 1 level ternary an ICU select expression:
Hello, { props.world, select, =true {world} =false {guys} }
Or i'm overengineering...
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.
Select
needs to always have the other
case, so I don't really see a way how to do that.
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.
Hello, { props.world, select, =true {world} other {guys} }
But it's overengineering anyway
"lib": [ | ||
"ES2019.Array" | ||
], |
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.
This is for Array.prototype.flat / Array.prototype.flatMap
Supported started from Node.js 11 AFAIK
one: [ | ||
{ | ||
type: "arg", | ||
name: "gender", | ||
type: "Identifier", | ||
}), | ||
format: "select", | ||
options: { | ||
male: "he", | ||
female: "she", | ||
other: "they", | ||
value: expect.objectContaining({ | ||
name: "gender", | ||
type: "Identifier", | ||
}), | ||
format: "select", | ||
options: { | ||
male: "he", | ||
female: "she", | ||
other: "they", | ||
}, | ||
}, | ||
}, | ||
], |
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.
Was a single element - become an array
…ences from babel-macro-plugin
3a00d7a
to
b24690d
Compare
* refactor(macro): pass down and manipulate with `path` instead of `node` * feature(macro): support JSX macro inside conditional expressions * refactor(macro): remove alreadyVisitedCache in favor of dedupe references from babel-macro-plugin
Description
This PR adding syntax support for
ConditionalExpressions
in JSX Macro:To make reviewing easier, i split changes into 2 commits.
path
instead ofnode
We need
path
because babel doesn't allow traversing over plainnode
. And manual traversing wasn't a case here because there might be a syntax which we didn't expect. (multiple nested ternaries or function call which accepts jsx node, etc)Also issue in SWC version repo: lingui/swc-plugin#16
Types of changes
fixes: #1175
Checklist