babel / babel/proposals

Throw Expressions (Stage 2)

Open
#23 5 comments 0 reactions 0 assignees View on GitHub
Proposal Issue Transform: Done
Dominant language
No language data
Stars
435
Forks
23
PR merge metrics
No merged PRs in 30d

Description

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:

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

## Implementation

- [x] Parser
- [x] Transform
- TS: https://github.com/Microsoft/TypeScript/pull/18798
- REPL: https://babeljs.io/repl/build/master#?&browsers=&build=&code_lz=DYSwdgLgFAhgzhANAAgN7IFDOQdxBACwC5koBKZAXgD5lCAnAex2TAFMWBRep-qAIhgA3RiAAmyAK5xwAc2QByPIQXIEMCGwC2bSHAB0_MhgC-ZANwYgA&circleciRepo=&lineWrap=true&presets=stage-0&targets=&version=7.0.0-beta.2

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked proposal repository and the issue's Implementation checklist. Review the parser and transform entries, then compare the TypeScript pull request and Babel REPL links with the current proposal status. The issue does not define a remaining change or a clear completion condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.