diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 25fff43bab7..28c9fb25af9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -578,7 +578,7 @@ namespace ts { function cloneSymbol(symbol: Symbol): Symbol { const result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt new file mode 100644 index 00000000000..5c1d4ec5026 --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.errors.txt @@ -0,0 +1,15 @@ +/b.ts(2,15): error TS2300: Duplicate identifier 'prototype'. + + +==== /a.d.ts (0 errors) ==== + declare class Foo {} + +==== /b.ts (1 errors) ==== + declare namespace Foo { + namespace prototype { + ~~~~~~~~~ +!!! error TS2300: Duplicate identifier 'prototype'. + function f(): void; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/mergedClassWithNamespacePrototype.js b/tests/baselines/reference/mergedClassWithNamespacePrototype.js new file mode 100644 index 00000000000..fbacd3b8baa --- /dev/null +++ b/tests/baselines/reference/mergedClassWithNamespacePrototype.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/mergedClassWithNamespacePrototype.ts] //// + +//// [a.d.ts] +declare class Foo {} + +//// [b.ts] +declare namespace Foo { + namespace prototype { + function f(): void; + } +} + + +//// [b.js] diff --git a/tests/cases/compiler/mergedClassWithNamespacePrototype.ts b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts new file mode 100644 index 00000000000..e4b086ffd27 --- /dev/null +++ b/tests/cases/compiler/mergedClassWithNamespacePrototype.ts @@ -0,0 +1,9 @@ +// @Filename: /a.d.ts +declare class Foo {} + +// @Filename: /b.ts +declare namespace Foo { + namespace prototype { + function f(): void; + } +}