Skip to content

Commit 39040f6

Browse files
author
Andy Hanson
committed
Provide better error message
1 parent 7beeb77 commit 39040f6

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ namespace ts {
479479
}
480480
recordMergedSymbol(target, source);
481481
}
482+
else if (target.flags & SymbolFlags.NamespaceModule) {
483+
error(source.valueDeclaration.name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target));
484+
}
482485
else {
483486
const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable
484487
? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0;

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,10 @@
18071807
"category": "Error",
18081808
"code": 2608
18091809
},
1810+
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
1811+
"category": "Error",
1812+
"code": 2649
1813+
},
18101814
"Cannot emit namespaced JSX elements in React": {
18111815
"category": "Error",
18121816
"code": 2650
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2300: Duplicate identifier '"lib"'.
2-
/node_modules/lib/index.d.ts(1,13): error TS2300: Duplicate identifier '"lib"'.
3-
/node_modules/lib/index.d.ts(2,19): error TS2300: Duplicate identifier '"lib"'.
1+
/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity.
42

53

6-
==== /node_modules/lib/index.d.ts (2 errors) ====
4+
==== /node_modules/lib/index.d.ts (0 errors) ====
75
declare var lib: () => void;
8-
~~~
9-
!!! error TS2300: Duplicate identifier '"lib"'.
106
declare namespace lib {}
11-
~~~
12-
!!! error TS2300: Duplicate identifier '"lib"'.
137
export = lib;
148

159
==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ====
1610
import * as lib from "lib";
1711
declare module "lib" {
1812
~~~~~
19-
!!! error TS2300: Duplicate identifier '"lib"'.
13+
!!! error TS2649: Cannot augment module 'lib' with value exports because it resolves to a non-module entity.
2014
export function fn(): void;
2115
}
2216

0 commit comments

Comments
 (0)