add isBlockedScoped types helper
This commit is contained in:
parent
d360bd5bb7
commit
774cb66d9b
@ -135,7 +135,7 @@ Scope.prototype.getInfo = function () {
|
||||
if (t.isFor(block)) {
|
||||
_.each(FOR_KEYS, function (key) {
|
||||
var node = block[key];
|
||||
if (t.isLet(node)) add(node);
|
||||
if (t.isBlockScoped(node)) add(node);
|
||||
});
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ Scope.prototype.getInfo = function () {
|
||||
if (t.isBlockStatement(block) || t.isProgram(block)) {
|
||||
_.each(block.body, function (node) {
|
||||
// check for non-var `VariableDeclaration`s
|
||||
if (t.isLet(node)) add(node);
|
||||
if (t.isBlockScoped(node)) add(node);
|
||||
});
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ Scope.prototype.getInfo = function () {
|
||||
|
||||
// we've ran into a declaration!
|
||||
// we'll let the BlockStatement scope deal with `let` declarations unless
|
||||
if (t.isDeclaration(node) && !t.isLet(node)) {
|
||||
if (t.isDeclaration(node) && !t.isBlockScoped(node)) {
|
||||
state.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -497,6 +497,17 @@ t.isLet = function (node) {
|
||||
return t.isVariableDeclaration(node) && (node.kind !== "var" || node._let);
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @param {Object} node
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
|
||||
t.isBlockScoped = function (node) {
|
||||
return t.isFunctionDeclaration(node) || t.isLet(node);
|
||||
};
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user