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

Allow variable declaration in if condition statements #14309

Closed
miniak opened this issue Feb 25, 2017 · 1 comment
Closed

Allow variable declaration in if condition statements #14309

miniak opened this issue Feb 25, 2017 · 1 comment
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints

Comments

@miniak
Copy link

miniak commented Feb 25, 2017

Example:

if (let element = document.getElementyById('foobar')) {
    element.someMethod();
}

This allows to have the variable properly block scoped, making it only available in the conditional block body. It should be possible to use const and let.

@DanielRosenwasser DanielRosenwasser added the Out of Scope This idea sits outside of the TypeScript language design constraints label Feb 25, 2017
@DanielRosenwasser
Copy link
Member

As much as I've liked this in other languages, it will probably not get implemented by us unless ECMAScript itself pursues it.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Out of Scope This idea sits outside of the TypeScript language design constraints
Projects
None yet
Development

No branches or pull requests

2 participants