Handle merging unknownSymbol (#28453)

* Handle merging unknownSymbol

* mergeSymbol of unknown target returns source, not unknown
This commit is contained in:
Andy 2018-11-19 10:51:58 -08:00 committed by Nathan Shively-Sanders
parent dc03115d14
commit b8a8ceae86
5 changed files with 43 additions and 1 deletions

View File

@ -870,7 +870,11 @@ namespace ts {
(source.flags | target.flags) & SymbolFlags.Assignment) {
Debug.assert(source !== target);
if (!(target.flags & SymbolFlags.Transient)) {
target = cloneSymbol(resolveSymbol(target));
const resolvedTarget = resolveSymbol(target);
if (resolvedTarget === unknownSymbol) {
return source;
}
target = cloneSymbol(resolvedTarget);
}
// Javascript static-property-assignment declarations always merge, even though they are also values
if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) {

View File

@ -0,0 +1,13 @@
/a.d.ts(2,10): error TS2708: Cannot use namespace 'N' as a value.
/a.d.ts(3,1): error TS2303: Circular definition of import alias 'N'.
==== /a.d.ts (2 errors) ====
declare global { namespace N {} }
export = N;
~
!!! error TS2708: Cannot use namespace 'N' as a value.
export as namespace N;
~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2303: Circular definition of import alias 'N'.

View File

@ -0,0 +1,11 @@
=== /a.d.ts ===
declare global { namespace N {} }
>global : Symbol(global, Decl(a.d.ts, 0, 0))
>N : Symbol(N, Decl(a.d.ts, 0, 16))
export = N;
>N : Symbol(N, Decl(a.d.ts, 0, 16))
export as namespace N;
>N : Symbol(N, Decl(a.d.ts, 1, 11))

View File

@ -0,0 +1,10 @@
=== /a.d.ts ===
declare global { namespace N {} }
>global : any
export = N;
>N : any
export as namespace N;
>N : any

View File

@ -0,0 +1,4 @@
// @Filename: /a.d.ts
declare global { namespace N {} }
export = N;
export as namespace N;