Repository navigation
Trailing Commas in Function Param Lists #7279
Description
Activity
- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptIn DiscussionNot yet reached consensusNot yet reached consensus
on Feb 28, 2016 - addedCommittedThe team has roadmapped this issueThe team has roadmapped this issueand removedIn DiscussionNot yet reached consensusNot yet reached consensus
on Mar 8, 2016 RyanCavanaugh commented
on Mar 8, 2016 MemberMore actionsApproved for whatever the Stage 3 proposal says
PRs are welcomed of course. the change should be limited to the parser, so would be a rather easy change to make.
DanielRosenwasser commented
on Mar 8, 2016 MemberMore actionsActually, signature help and overload resolution could potentially be affected by this.
Is anyone taking on this? If not I can. I spent almost my entire weekend playing with the parser and scanner.
Daniel Rosenwasser (@DanielRosenwasser), what do you mean by signature help and overload resolution?
Noj Vek (@nojvek) there is a PR for this already in #7747. if you want to take that over and respond to code review comments we can get it in.
DanielRosenwasser commented
on May 23, 2016 MemberMore actionsNoj Vek (@nojvek) signature help is the little tooltip that shows up to show the parameters & their types when you call a function.
I mean that we specifically check if you have a trailing comma to see if there is a "better" overload in some cases.
For instance, here's a call to
localeComparewith one argument:Here's a call with one argument and a trailing comma:
DanielRosenwasser commented
on May 23, 2016 MemberMore actionsSo in general, my warning is that we can't do that anymore if we support trailing commas in argument lists. If we do that, we'd impair the experience of anyone who wants to use trailing commas in calls.
do not think this is an issue we should change the design of signature help for. you will get the pop up, you could decide to dismiss it an keep the comma.
Reacted by Joe Skeen- addedES NextNew featurers for ECMAScript (a.k.a. ESNext)New featurers for ECMAScript (a.k.a. ESNext)
on Jun 6, 2016 - addedFixedA PR has been merged for this issueA PR has been merged for this issue
on Jun 7, 2016 Woohoo!
Personal opinion to any users : If you are thinking about adding a trailing comma to a function you might want to reconsider and change the function parameters to a single object https://basarat.gitbooks.io/typescript/content/docs/tips/functionParameters.html 🌹
Reacted by Judah Gabriel Himango, Quack, David Sherret and AJP / James Phillips- added a commit that references this issue
on Sep 2, 2016 - locked and limited conversation to collaborators
on Jun 19, 2018



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:
Benefits: https://github.com/jeffmo/es-trailing-function-commas/blob/master/proposal_presentation_slides.pdf
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
privateannotations, and possibly areadonlyannotation coming down the pipe.