Handle undefined symbol.declarations in cloneSymbol (#18474)

This commit is contained in:
Andy
2017-09-14 13:03:12 -07:00
committed by GitHub
parent b934c8bcbd
commit 66abcb9166
4 changed files with 39 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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]

View File

@@ -0,0 +1,9 @@
// @Filename: /a.d.ts
declare class Foo {}
// @Filename: /b.ts
declare namespace Foo {
namespace prototype {
function f(): void;
}
}