Search Terms
tsx attribute shorthand, object shorthand
Suggestion
ES6 has this great syntax of passing key value pairs in objects e.g.
function swahili() {
const hello = 'jambo';
const great = 'sawa';
return {hello, great};
}
but in TSX land this doesn't transfer well e.g.
function render() {
const hello = 'jambo';
const great = 'sawa';
return <Greetings {hello, great} />
}
typescript throws an error that it needs a TS1005: '...' expected.
It instead needs to be written as
function render() {
const hello = 'jambo';
const great = 'sawa';
return <Greetings {...{hello, great}} />
}
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
<Foo hello={hello} world={world} />
<Foo {hello} {world} />
<foo {hello, world} />
They would all be emitted as
Use Cases
Examples
Checklist
My suggestion meets these guidelines:
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: