Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upOmitting semicolons is not future-proof #581
Comments
dcousens
added
the
question
label
Aug 3, 2016
This comment has been minimized.
This comment has been minimized.
|
I think you're throwing the baby out with the bath water. Cases like get/set/static would fall in the realm of "necessary' semicolons, like those in for loops, and appears easy to identify. Perhaps we need to add a few more semicolons in, no drama. Standard isn't so zealous about "no semicolons" that it's going to disallow/break valid JavaScript constructs just because they require semicolons. Standard simply enforces no unnecessary semicolons. Adding new rules to handle new syntax is an inevitability. I don't see any problem here. |
This comment has been minimized.
This comment has been minimized.
|
@bakkot thanks for the feedback. You raise an interesting point, but like Tim said we'll add new rules when new syntax is introduced. Closing because there's not really anything to be done here now |
yoshuawuyts
closed this
Aug 3, 2016
This comment has been minimized.
This comment has been minimized.
|
For posterity, this is related to #372. |
This comment has been minimized.
This comment has been minimized.
jamesplease
commented
Jan 11, 2018
|
Cross-referencing tc39/ecma262#1062 , which seems related. tl;dr, TC39 discourages the practice of relying on ASI. |
This comment has been minimized.
This comment has been minimized.
|
@jmeas I responded tc39/ecma262#1062 (comment) I think they could improve their neutrality and suggested a re-wording on the issue to more accurately and fairly represent the issue. |
bakkot commentedAug 3, 2016
•
edited
Consider for example the public fields proposal.
Under it, this is valid code:
and this is a syntax error:
You could add a rule which says that class fields must always start or end with a semicolon (or some other, even more special-case-y rule), but it's more overhead to remember.
I don't mean to rehash the great semicolon debate; I just wanted to point out that this style is only going to become harder and harder to follow as the language evolves.
(Incidentally, Babel's parsing of class properties is fairly broken, so don't rely on it as an oracle here.)
is legal; it's just 'get', 'set', 'static', and similar names which have this issue. ASI will not put a semicolon in the second snippet above because in class bodies an identifier such as 'set' is in fact a legal token to follow 'get' without an intervening semicolon.