mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
do not treat property names in binding elements as block scoped variables
This commit is contained in:
@@ -5091,13 +5091,20 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
// - check if binding is used in some function
|
||||
// - check if binding is used in some function
|
||||
// (stop the walk when reaching container of binding declaration)
|
||||
// - if first check succeeded - check if variable is declared inside the loop
|
||||
|
||||
// var decl -> var decl list -> parent
|
||||
var container = (<VariableDeclaration>symbol.valueDeclaration).parent.parent;
|
||||
// nesting structure:
|
||||
// (variable declaration or binding element) -> variable declaration list -> container
|
||||
var container: Node = symbol.valueDeclaration;
|
||||
while (container.kind !== SyntaxKind.VariableDeclarationList) {
|
||||
container = container.parent;
|
||||
}
|
||||
// get the parent of variable declaration list
|
||||
container = container.parent;
|
||||
if (container.kind === SyntaxKind.VariableStatement) {
|
||||
// if parent is variable statement - get its parent
|
||||
container = container.parent;
|
||||
}
|
||||
|
||||
@@ -10722,6 +10729,12 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// ignore property names in object binding patterns
|
||||
if (n.parent.kind === SyntaxKind.BindingElement &&
|
||||
(<BindingElement>n.parent).propertyName === n) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// for names in variable declarations and binding elements try to short circuit and fetch symbol from the node
|
||||
var declarationSymbol: Symbol =
|
||||
(n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n) ||
|
||||
|
||||
Reference in New Issue
Block a user