@strict class decorator

Naveen Chawla naveen.chwl at gmail.com
Tue Aug 8 05:14:04 UTC 2017

So here it is, the holy grail of allowing classes to have fixed

OK what do I mean?


export class Person{

is followed by

const person = new Person();
person.age = 27;

I would like to see the IDE flag it as " "age" is not a property in strict
class "Person" "

This reminds the developer to then add age as a property, thereby ensuring
every instance of the class always has full autocomplete, quick property
renaming etc. across the project, for all properties added to it. For large
projects with multiple developers this can also have the benefit of
ensuring that all properties added to each instance are necessarily
documented in one place, instead of checking whether someone has
dynamically added a property somewhere.

I would expect this example to throw a runtime exception like @readonly
does. I don't think that's a problem because I think the IDE would inform
much sooner. But I'm open to the idea of the runtime allowing it, since the
real benefit for me is during development. Maybe instead a `@strictDev`
decorator for that behavior, not sure.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170808/7bcb1afb/attachment.html>

More information about the es-discuss mailing list