Skip to content

Support "use strong"; prologue #5010

Closed
Closed

Description

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".

Activity

  1. kitsonk commented on Oct 1, 2015

    @kitsonk
    Contributor

    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.)

  2. weswigham commented on Oct 1, 2015

    @weswigham
    MemberAuthor

    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.

  3. ivogabe commented on Oct 8, 2015

    @ivogabe
    Contributor

    +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.

  4. weswigham commented on Feb 23, 2016

    @weswigham
    MemberAuthor

    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.

  5. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions