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; diff --git a/tests/baselines/reference/testContainerList.js b/tests/baselines/reference/testContainerList.js new file mode 100644 index 00000000000..d7e91a59256 --- /dev/null +++ b/tests/baselines/reference/testContainerList.js @@ -0,0 +1,19 @@ +//// [testContainerList.ts] +// Regression test for #325 +module A { + class C { + constructor(public d: {}) { } + } +} + + +//// [testContainerList.js] +var A; +(function (A) { + var C = (function () { + function C(d) { + this.d = d; + } + return C; + })(); +})(A || (A = {})); diff --git a/tests/cases/compiler/testContainerList.ts b/tests/cases/compiler/testContainerList.ts new file mode 100644 index 00000000000..29a4fbd206c --- /dev/null +++ b/tests/cases/compiler/testContainerList.ts @@ -0,0 +1,6 @@ +// Regression test for #325 +module A { + class C { + constructor(public d: {}) { } + } +}