You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v8 (and node 4) have an in-progress implementation of the proposed use strong mode. According to this presentation there are plans to make a formal proposal to the ECMA at some time in the future, but given that both chrome and node already implement much of it (albeit behind a flag) it could be used/useful already. Minimally, we could start by recognizing the "use strong" prologue as a form of "use strict".
For those who don't want to dig through the presentation, outside of run-time enforcement of typings (in the TypeScript style) strong mode enforces the following:
Remove support for var, instead let or const would be used.
No undeclared variables
No use before declaration, except for recursive function calls.
Accessing missing properties throws
Objects created in strong mode are not extensible
Non-configurable properties cannot be frozen
class prototypes are frozen
class instances are sealed
methods require proper instances
Array are non-sparse
arguments is eliminated (use ...args)
calling with too few arguments throws (use optional args)
No implicit coercion (except toBoolean)
== and != require compatible typeof
There is a lot more on the "StrongScript" typing that the presentation doesn't make fully clear. I also haven't (yet) tried to see what they have built so far. There is clearly some parts of the second part of the proposal, around typing that wouldn't be fully compatible with TypeScript (for example they have nominal classes for structural typing, they allow explicit typing of this, etc.)
The typing parts of their proposal are a separate "SoundScript" extension and are proposed to be used with the prologue "use strong+types";. For now, that part seems a longer way off than the simple strong mode semantic changes, so I don't think we need to worry about it yet. For a minimum amount of work, "use strong "; is supposed to include all use strict restrictions, so we could begin by recognizing it as a form of the use strict prologue.
+1 on this one. The emit must change in some situations, for example an enum should use a const instead of a variable and (if I understand correctly) the whole enum should be written as one big object literal. Helper functions should be written using a const (or let) too and I'm not yet sure if decorators can be used.
Activity
kitsonk commentedon Oct 1, 2015
For those who don't want to dig through the presentation, outside of run-time enforcement of typings (in the TypeScript style) strong mode enforces the following:
var, insteadletorconstwould be used.argumentsis eliminated (use...args)==and!=require compatibletypeofThere is a lot more on the "StrongScript" typing that the presentation doesn't make fully clear. I also haven't (yet) tried to see what they have built so far. There is clearly some parts of the second part of the proposal, around typing that wouldn't be fully compatible with TypeScript (for example they have nominal classes for structural typing, they allow explicit typing of
this, etc.)weswigham commentedon Oct 1, 2015
The typing parts of their proposal are a separate "SoundScript" extension and are proposed to be used with the prologue
"use strong+types";. For now, that part seems a longer way off than the simple strong mode semantic changes, so I don't think we need to worry about it yet. For a minimum amount of work,"use strong ";is supposed to include all use strict restrictions, so we could begin by recognizing it as a form of the use strict prologue.sebilasse commentedon Oct 8, 2015
also: https://www.sitepen.com/blog/2015/10/08/stronger-javascript/
ivogabe commentedon Oct 8, 2015
+1 on this one. The emit must change in some situations, for example an enum should use a
constinstead of a variable and (if I understand correctly) the whole enum should be written as one big object literal. Helper functions should be written using aconst(orlet) too and I'm not yet sure if decorators can be used.weswigham commentedon Feb 23, 2016
Strong mode is dead, so we don't need to worry about supporting it. Though I'd still keep an eye on what their type annotation plans are.