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
consterrorThrowExp=()=>{thrownewError('Error!');}functionerrorThrowFn(maybeTrue){if(maybeTrue){return ...;}else{thrownewError('Error!');}}js
consterrorThrowExp=function(){thrownewError('Error!')}functionerrorThrowFn(maybeTrue){if(maybeTrue){return ...;}else{thrownewError('Error!');}}Proposal
ts
consterrorThrower=()=>thrownewError('Error!');functionerrorThrowFn(maybeTrue: boolean){returnmaybeTrue? ...: thrownewError('Error!');}js
consterrorThrower=function(){thrownewError('Error!');}functionerrorThrowFn(maybeTrue: boolean){returnmaybeTrue? ...: (function(){thrownewError('Error!')})();}
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
js
Proposal
ts
js