Closed
Description
https://jeffmo.github.io/es-trailing-function-commas/
This proposal is Stage 3 according to https://github.com/tc39/ecma262, so seems like its at an appropriate stability for TypeScript team to implement it.
This would allow function definitions and calls in the following style:
function foo(
bar: Bar, // Comment about bar
baz: Baz, // Comment about baz
) {
// Implementation...
}
foo(
bar,
baz,
);
Benefits: https://github.com/jeffmo/es-trailing-function-commas/blob/master/proposal_presentation_slides.pdf
- Helps with VCS authorship attribution in case of added/removed parameters
- Consistency with object and array literals
- Lintable (if you don't like the style, can ban it in your codebase with a linter)
- Supported by other languages
In addition to all of the above, I suspect the extra "verbosity" of TypeScript's inline types makes this feature even more attractive in TypeScript than in vanilla JS. I feel this particularly in class constructors, which can also have private
annotations, and possibly a readonly
annotation coming down the pipe.
class Foo {
constructor(
private bar: Bar = new BasicBar(),
private baz: Baz = new BasicBaz(),
) {}
}