Skip to content

Commit a859399

Browse files
authored
Merge pull request #15258 from Microsoft/mergeSymbol-uses-first-decl-not-valueDecl
mergeSymbol uses first declaration, not valueDeclaration
2 parents b8b801b + eba15f4 commit a859399

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ namespace ts {
574574
recordMergedSymbol(target, source);
575575
}
576576
else if (target.flags & SymbolFlags.NamespaceModule) {
577-
error(source.valueDeclaration.name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target));
577+
error(source.declarations[0].name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target));
578578
}
579579
else {
580580
const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests/cases/compiler/final.ts(1,6): error TS2649: Cannot augment module 'A' with value exports because it resolves to a non-module entity.
2+
3+
4+
==== tests/cases/compiler/initial.ts (0 errors) ====
5+
interface A { }
6+
namespace A {}
7+
8+
==== tests/cases/compiler/final.ts (1 errors) ====
9+
type A = {}
10+
~
11+
!!! error TS2649: Cannot augment module 'A' with value exports because it resolves to a non-module entity.
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//// [tests/cases/compiler/noSymbolForMergeCrash.ts] ////
2+
3+
//// [initial.ts]
4+
interface A { }
5+
namespace A {}
6+
7+
//// [final.ts]
8+
type A = {}
9+
10+
11+
//// [initial.js]
12+
//// [final.js]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @Filename: initial.ts
2+
interface A { }
3+
namespace A {}
4+
5+
// @Filename: final.ts
6+
type A = {}

0 commit comments

Comments
 (0)