Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the ECMAScript 'throw' operator #18798

Closed
wants to merge 4 commits into from
Closed

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Sep 27, 2017

This PR adds support for the stage-2 ECMAScript 'throw' operator: https://github.com/tc39/proposal-throw-expressions.

NOTE: This feature does not yet support reachability checks at the expression level (e.g. in (throw x), y, y should be considered unreachable). I can investigate this either as part of this PR or (preferably) in a follow-up PR. Our current reachability algorithm does not work well with expressions and will require some further investigation to make it more robust.

Fixes: #18535

@weswigham
Copy link
Member

@rbuckton Can you include a link to the ECMAScript proposal in the OP, for posterity?

@rbuckton
Copy link
Member Author

@weswigham, I've updated the description. I was waiting on the transfer of the proposal repository to the tc39 organization.

@weswigham
Copy link
Member

👍

@rbuckton
Copy link
Member Author

I'm going to add an --experimentalThrowExpressions option before this is merged.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 2, 2017

Based on today's discussion (#18895), we want to hold off on this untill it makes stage 3, then include it without a flag.

@mihailik
Copy link
Contributor

Are there plans for a similar try expression?

const _crypto = try { require('crypto') } catch { }

@plantain-00
Copy link
Contributor

@mihailik
need to propose it tc39 first https://github.com/tc39/proposals

@mihailik
Copy link
Contributor

@plantain-00 not really, in fact it often goes in the opposite direction.

@Jessidhia
Copy link

Jessidhia commented Oct 12, 2017

@mihailik nope, that is exactly how it is supposed to be done -- via TC39. TypeScript is not adding any additional syntax that is not being tracked by TC39, besides the current syntax that is being grandfathered in (as, namespace, enum) and JSX.

At any rate, I expect that, were you to propose it right now, it would get deferred in favor of do expressions. Alternatively, a proposal to also convert if/for/while into expressions.

@typescript-bot
Copy link
Collaborator

Thanks for your contribution. This PR has not been updated in a while and cannot be automatically merged at the time being. For housekeeping purposes we are closing stale PRs. If you'd still like to continue working on this PR, please leave a message and one of the maintainers can reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants