mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 01:33:15 -05:00
Handle undefined symbol.declarations in cloneSymbol (#18474)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
@@ -0,0 +1,9 @@
|
||||
// @Filename: /a.d.ts
|
||||
declare class Foo {}
|
||||
|
||||
// @Filename: /b.ts
|
||||
declare namespace Foo {
|
||||
namespace prototype {
|
||||
function f(): void;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user