mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
added SyntaxKind.ModuleDeclaration to list of block scope containers
This commit is contained in:
@@ -5086,10 +5086,6 @@ module ts {
|
||||
return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node);
|
||||
}
|
||||
|
||||
function isNameScopeBoundary(n: Node): boolean {
|
||||
return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
function checkBlockScopedBindingCapturedInLoop(node: Identifier, symbol: Symbol): void {
|
||||
if (languageVersion >= ScriptTarget.ES6 || (symbol.flags & SymbolFlags.BlockScopedVariable) === 0) {
|
||||
return;
|
||||
@@ -5116,7 +5112,7 @@ module ts {
|
||||
}
|
||||
|
||||
var current: Node = container;
|
||||
while (current && !isNameScopeBoundary(current)) {
|
||||
while (current && !nodeStartsNewLexicalEnvironment(current)) {
|
||||
if (isIterationStatement(current, /*lookInLabeledStatements*/ false)) {
|
||||
if (inFunction) {
|
||||
grammarErrorOnFirstToken(current, Diagnostics.Code_in_the_loop_captures_block_scoped_variable_0_in_closure_This_is_natively_supported_in_ECMAScript_6_or_higher, declarationNameToString(node));
|
||||
|
||||
@@ -3832,21 +3832,20 @@ module ts {
|
||||
return current;
|
||||
}
|
||||
switch (current.kind) {
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.SwitchKeyword:
|
||||
case SyntaxKind.CatchClause:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.ForOfStatement:
|
||||
case SyntaxKind.SwitchKeyword:
|
||||
return current;
|
||||
case SyntaxKind.Block:
|
||||
if (isAnyFunction(current.parent)) {
|
||||
return current.parent;
|
||||
}
|
||||
else {
|
||||
// function block is not considered block-scope container
|
||||
// see comment in binder.ts: bind(...), case for SyntaxKind.Block
|
||||
if (!isAnyFunction(current.parent)) {
|
||||
return current;
|
||||
}
|
||||
case SyntaxKind.SourceFile:
|
||||
return current;
|
||||
}
|
||||
|
||||
current = current.parent;
|
||||
|
||||
@@ -1117,6 +1117,11 @@ module ts {
|
||||
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength: */newEndN - oldStartN);
|
||||
}
|
||||
|
||||
// @internal
|
||||
export function nodeStartsNewLexicalEnvironment(n: Node): boolean {
|
||||
return isAnyFunction(n) || n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.SourceFile;
|
||||
}
|
||||
|
||||
// @internal
|
||||
export function nodeIsSynthesized(node: Node): boolean {
|
||||
return node.pos === -1 && node.end === -1;
|
||||
|
||||
Reference in New Issue
Block a user