Closed as not planned
Description
Support proposal-throw-expressions.
That proposal is now stage-1, but worth to implements for convenience and this proposal not break backward-compatibilities.
Current
ts
const errorThrowExp = () => { throw new Error('Error!'); }
function errorThrowFn(maybeTrue) {
if (maybeTrue){
return ...;
} else {
throw new Error('Error!');
}
}
js
const errorThrowExp = function() {throw new Error('Error!')}
function errorThrowFn(maybeTrue) {
if (maybeTrue){
return ...;
} else {
throw new Error('Error!');
}
}
Proposal
ts
const errorThrower = () => throw new Error('Error!');
function errorThrowFn(maybeTrue: boolean) {
return maybeTrue? ...: throw new Error('Error!');
}
js
const errorThrower = function() { throw new Error('Error!'); }
function errorThrowFn(maybeTrue: boolean) {
return maybeTrue? ...: (function() { throw new Error('Error!') })();
}