Skip to content

Throw Expressions (Stage 2) #23

Open
@hzoo

Description

@hzoo

Champions: Ron Buckton (@rbuckton)
Spec Repo: https://github.com/rbuckton/proposal-throw-expressions
First presented at the July 2017 meeting: https://github.com/tc39/agendas/blob/master/2017/07.md
Stage 1 to Stage 2 at Sept 2017 meeting

Examples:

function save(filename = throw new TypeError("Argument required")) {}
lint(ast, { 
  with: () => throw new Error("avoid using 'with' statements.")
});
function getEncoder(encoding) {
  const encoder = encoding === "utf8" ? new UTF8Encoder() 
                : encoding === "utf16le" ? new UTF16Encoder(false) 
                : encoding === "utf16be" ? new UTF16Encoder(true) 
                : throw new Error("Unsupported encoding");
}
class Product {
  get id() { return this._id; }
  set id(value) { this._id = value || throw new Error("Invalid value"); }
}

Implementation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions