DEV Community

Discussion on: JavaScript Class Improvements

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

I'd really like to have a strict mode for fields as well: only declared fields exist. Right now typos can ruin everything, when you have this.itemList in the constructor and assign to this.itmeList elsewhere, then spend a half-day scratching you head wondering why some bits of the code don't work!

Collapse
 
kayis profile image
K

Guess that's what you get with dynamic typing :D

Collapse
 
renannobile profile image
Renan Lourençoni Nobile

Isn't "use strict" the solution for that kind of situation?

Collapse
 
kayis profile image
K

Sadly no.

TypeScript or Flow are the solution.