"Duplicate declaration" warning for Javascript variable defined in if/else statement?

When I do something like this in a JS file:

if (foo) {
    var bar = true;
} else {
    var bar = false;

PhpStorm shows a ""Duplicate declaration" warning in the editor. I don't think the warning should be shown, because it's not a duplicate declaration. As far as I know, this is the syntactically correct way to create a variable of this nature.

Please sign in to leave a comment.