Skip to content

Support 'throw' expressions #18535

Description

@brn

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!')})();}

Metadata

Metadata

Assignees

No one assigned

    Labels

    ES NextNew featurers for ECMAScript (a.k.a. ESNext)SuggestionAn idea for TypeScriptWaiting for TC39Unactionable until TC39 reaches some conclusion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions