Skip to content

Normative: allow trailing comma in set parameter list - #4095

Open
JLHwung wants to merge 1 commit into
tc39:mainfrom
JLHwung:allow-trailing-comma-set-parameter-list
Open

JLHwung wants to merge 1 commit into
tc39:mainfrom
JLHwung:allow-trailing-comma-set-parameter-list

Conversation

@JLHwung

@JLHwung JLHwung commented Nov 19, 2026

Copy link
Copy Markdown

In this PR we propose to allow the trailing comma in the setter parameter list:

class C {
  set p(v,) {}
}

var o = {
  set p(v,) {}
}

V8 and popular tools like acorn, Babel, TypeScript all allow such case, while FF and JSC currently reject it according to the spec.

The fact that |FormalParameters| allows trailing comma but |PropertySetParameterList| does not seems like overlook. I have open an issue to V8 and asked their opinion (https://issues.chromium.org/issues/569770965), they agree that "Maybe allowing the trailing comma in the spec is the best thing here".

@bakkot

bakkot commented Nov 19, 2026

Copy link
Copy Markdown
Member

It wasn't an oversight; the point of trailing commas is to allow writing multiple items across multiple lines without needing to edit the last one when you add a new item, like

foo(
  x,
  y,
  z,
)

but this does not apply to setters because they have exactly one parameter.

@nicolo-ribaudo nicolo-ribaudo added normative change Affects behavior required to correctly evaluate some ECMAScript source text needs consensus This needs committee consensus before it can be eligible to be merged. labels Nov 20, 2026
@linusg linusg added the needs test262 tests The proposal should specify how to test an implementation. Ideally via github.com/tc39/test262 label Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs consensus This needs committee consensus before it can be eligible to be merged. needs test262 tests The proposal should specify how to test an implementation. Ideally via github.com/tc39/test262 normative change Affects behavior required to correctly evaluate some ECMAScript source text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants