Repository navigation
TSX support attribute object literal shorthand #31797
Description
Activity
Ryan Cavanaugh (@RyanCavanaugh) ^
Since you're the TSX expert, I assume you may have thoughts on it.
This is better proposed to the JSX spec. If it's accepted there, it'll surely find its way into Typescript
Reacted by Titian Cernicova-Dragomir and jwbayProposed for the JSX spec here: react/jsx#23
said JSX pr with BNF grammar change: react/jsx#118
The problem I find with proposals to the JSX spec is that they go untouched for years. This issue was created in 2014, and has had no action. Another issue (react/jsx#66) was created in 2016 and is a relatively trivial change.
Even worse, there is no response from the maintainers even after being directly pinged. That's the case in both issues.
TypeScript is a superset of JavaScript, why not also make it a superset of JSX?
- addedExternalRelates to another program, environment, or user action which we cannot control.Relates to another program, environment, or user action which we cannot control.
on Jun 13, 2019 RyanCavanaugh commented
on Jun 13, 2019 MemberMore actionsThese proposals need to start with the JSX folks.
I'm vaguely surprised (but happy) it doesn't already parse as a sequence expression 😅
Just curious, What do you mean by sequence expression?
Yeah jsx folks have been non-active for years. I tried pinging some contributors so let’s see where this goes.
RyanCavanaugh commented
on Jun 13, 2019 MemberMore actionsThe expression
a, b(e.g.1 + (2, 3) === 4) evaluatesa, evaluatesb, and produces the right operand's result.I've just created react/jsx#119. Let's see what happens; I absolutely intend on forking the spec and updating it if Facebook doesn't consider proposals that have been open for multiple years.
Reacted by zhangenmingtypescript-bot commented
on Jun 17, 2019 ContributorMore actionsThis issue has been marked as 'External' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Search Terms
tsx attribute shorthand, object shorthand
Suggestion
ES6 has this great syntax of passing key value pairs in objects e.g.
but in TSX land this doesn't transfer well e.g.
typescript throws an error that it needs a
TS1005: '...' expected.It instead needs to be written as
which seems very boiler platey.
It would be awesome if we could make a small tweak to pass attributes like es6 shorthand.
so all of these would be equal
They would all be emitted as
Use Cases
Examples
Checklist
My suggestion meets these guidelines: