mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Handle merging unknownSymbol (#28453)
* Handle merging unknownSymbol * mergeSymbol of unknown target returns source, not unknown
This commit is contained in:
parent
dc03115d14
commit
b8a8ceae86
@ -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) {
|
||||
|
||||
@ -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'.
|
||||
|
||||
11
tests/baselines/reference/exportAsNamespaceConflict.symbols
Normal file
11
tests/baselines/reference/exportAsNamespaceConflict.symbols
Normal 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))
|
||||
|
||||
10
tests/baselines/reference/exportAsNamespaceConflict.types
Normal file
10
tests/baselines/reference/exportAsNamespaceConflict.types
Normal file
@ -0,0 +1,10 @@
|
||||
=== /a.d.ts ===
|
||||
declare global { namespace N {} }
|
||||
>global : any
|
||||
|
||||
export = N;
|
||||
>N : any
|
||||
|
||||
export as namespace N;
|
||||
>N : any
|
||||
|
||||
4
tests/cases/compiler/exportAsNamespaceConflict.ts
Normal file
4
tests/cases/compiler/exportAsNamespaceConflict.ts
Normal file
@ -0,0 +1,4 @@
|
||||
// @Filename: /a.d.ts
|
||||
declare global { namespace N {} }
|
||||
export = N;
|
||||
export as namespace N;
|
||||
Loading…
x
Reference in New Issue
Block a user