Ideas on type hinting and named parameters

Andrea Giammarchi andrea.giammarchi at
Tue Jun 9 20:34:10 UTC 2015

Inline replies

On Tue, Jun 9, 2015 at 9:01 PM, Kevin Smith <zenparsing at> wrote:
> Let's take a step back and ask:  what's the motivation for having these
> property declarations and initializers outside of the constructor?

The same motivation of having `static` properties definition in it ... it
was just possible to do the same directly through the class name without
needing a new syntax, right?

>   As Mark pointed out, it's a syntactic feature that is strictly less
> expressive than the current solution of putting property assignments in the
> constructor body.

You define a class and basic/default properties per each instance. That's
what people coming from other languages expect before even realizing
classes methods are not own properties or classes getters and setters are
not own descriptors.

It's a common, well known, pattern in the "class world" out there, that's
pretty much it. Since class in JS is sugar, why limiting such sugar?

> Instance property initializer syntax is really geared toward type systems,
> where you are expressing type constraints (either structural or nominal) on
> objects created by the given constructor.
> I'm wary of adding syntax whose primary motivation is to express type
> constraints, when we haven't even defined (or proposed) what typing in JS
> means.
Agreed we are mixing up two different things that don't necessarily need
each other to work.

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

More information about the es-discuss mailing list