diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index faf8d96e2be..7b16c785833 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -171,8 +171,13 @@ module ts { parent = node; if (symbolKind & SymbolFlags.IsContainer) { container = node; - if (lastContainer) lastContainer.nextContainer = container; - lastContainer = container; + // If container is not on container list, add it to the list + if (lastContainer !== container && !container.nextContainer) { + if (lastContainer) { + lastContainer.nextContainer = container; + } + lastContainer = container; + } } forEachChild(node, bind); container = saveContainer;