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
Add any syntax convenience for deconstructing a value object (or just for function parameters) without specifying each property.
Use Cases
For example, currently, when we need to define a function with something like a settings object (without an existing interface or type alias defined, for it should be where it belongs to), we must either access the properties like foobar.foo, foobar.bar with repeatedly a lot of foobar., or deconstruct it like
({ foo, bar, baz }: { foo: string, bar: number, baz: boolean }) => {
//...
}
But property names are duplicately specified, which is very painful and ungraceful especially when there are a lot of properties with long names.
which should extract all properties from the argument (which may depend on the type definition instead of the enumeration of keys, for not breaking the guidelines)
({ foo as string, bar as number, baz as boolean }) => {
//...
}
actually using ":" instead of "as" would be but it already means alias naming.
Checklist
My suggestion meets these guidelines:
This wouldn't be a breaking change in existing TypeScript/JavaScript code
This wouldn't change the runtime behavior of existing JavaScript code
This could be implemented without emitting different JS based on the types of the expressions
This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
Search Terms
deconstruct parameter
Suggestion
Add any syntax convenience for deconstructing a value object (or just for function parameters) without specifying each property.
Use Cases
For example, currently, when we need to define a function with something like a settings object (without an existing interface or type alias defined, for it should be where it belongs to), we must either access the properties like
foobar.foo
,foobar.bar
with repeatedly a lot offoobar.
, or deconstruct it likeBut property names are duplicately specified, which is very painful and ungraceful especially when there are a lot of properties with long names.
Examples
which should extract all properties from the argument (which may depend on the type definition instead of the enumeration of keys, for not breaking the guidelines)
actually using ":" instead of "as" would be but it already means alias naming.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: