Destructuring: Add early errors for empty patterns?

Standards Zakas standards at
Wed Oct 21 18:19:23 UTC 2015

Hi all,

In playing with destructuring, it seems like there are some syntax gotchas
that really should trigger some sort of error and instead fail silently.
For instance:

let {} = foo;

This line does absolutely nothing and is most likely an error on the
developer's part. However, this is completely valid syntax and not a
parsing error. Fortunately, it's pretty clear from looking at it that
there's a problem. Another example isn't so clear:

let { bar: {} } = foo;

This one, I'd argue, is even worse. It looks like it should do something,
but silently does nothing.

Is there any possibility to add an early error for empty destructuring
patterns (array and object)? It seems like this would save developers a lot
of trouble in the long run.

Nicholas C. Zakas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list