You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optional properties with object shorthand syntax #39376
Allow to specify optional properties in object shorthand syntax. If the variable is undefined, the property will not be added to the object (instead of being added with value undefined). Proposed syntax is to add a question mark to the property name, for example { prop1, prop2? }.
Use Cases
Goal is to create one object with a short clear (one-line) syntax.
Hmm, that's an interesting idea for a design proposal given the sorts of hacky object spread syntax I've seen in the past. It wouldn't really fit in the scope of TS, but it would be a reasonable ES proposal.
Activity
DanielRosenwasser commentedon Jul 3, 2020
Hmm, that's an interesting idea for a design proposal given the sorts of hacky object spread syntax I've seen in the past. It wouldn't really fit in the scope of TS, but it would be a reasonable ES proposal.
RyanCavanaugh commentedon Jul 8, 2020
There's always
I think this is out of scope for TS; it doesn't have anything to do with type checking
danielrentz commentedon Jul 9, 2020
OK thanks, I'll try my luck with an ES proposal.
danielrentz commentedon Jul 23, 2020
For the records. Just found an existing idea in the TC discuss groups: https://es.discourse.group/t/optional-property-shorthand-in-object-literal/196
Not much action since 2018 though...