File tree 4 files changed +14
-4
lines changed
4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 194
194
"Cannot extend a class '{0}'. Class constructor is marked as private." : 2675 ,
195
195
"The 'this' types of each signature are incompatible." : 2685 ,
196
196
"Namespace '{0}' has no exported member '{1}'." : 2694 ,
197
+ "Namespace can only have declarations." : 2695 ,
197
198
"Required type parameters may not follow optional type parameters." : 2706 ,
198
199
"Duplicate property '{0}'." : 2718 ,
199
200
"Property '{0}' is missing in type '{1}' but required in type '{2}'." : 2741 ,
Original file line number Diff line number Diff line change @@ -398,9 +398,14 @@ export class Parser extends DiagnosticEmitter {
398
398
tn . range ( declareStart , declareEnd ) , "declare"
399
399
) ; // recoverable
400
400
}
401
- if ( ! namespace ) {
401
+ if ( namespace ) {
402
+ this . error (
403
+ DiagnosticCode . Namespace_can_only_have_declarations ,
404
+ tn . range ( startPos )
405
+ ) ;
406
+ } else {
402
407
statement = this . parseStatement ( tn , true ) ;
403
- } // TODO: else?
408
+ }
404
409
}
405
410
break ;
406
411
}
Original file line number Diff line number Diff line change
1
+ let outerVar :i32 = 0 ;
1
2
declare namespace A {
2
3
namespace B {
3
4
export namespace C {
4
5
var aVar : i32 ;
6
+ outerVar = 42 ; // 2695: Namespace can only have declarations.
5
7
const aConst : i32 ;
6
8
const aConstInvalid : i32 = 0 ; // 1039: Initializers are not allowed in ambient contexts.
7
9
function aFunc ( ) : void ;
Original file line number Diff line number Diff line change
1
+ let outerVar : i32 = 0 ;
1
2
declare namespace A {
2
3
namespace B {
3
4
export namespace C {
@@ -14,5 +15,6 @@ declare namespace A {
14
15
}
15
16
}
16
17
}
17
- // ERROR 1039: "Initializers are not allowed in ambient contexts." in namespace.ts(6,32+1)
18
- // ERROR 1183: "An implementation cannot be declared in ambient contexts." in namespace.ts(8,37+1)
18
+ // ERROR 2695: "Namespace can only have declarations." in namespace.ts(6,7+0)
19
+ // ERROR 1039: "Initializers are not allowed in ambient contexts." in namespace.ts(8,32+1)
20
+ // ERROR 1183: "An implementation cannot be declared in ambient contexts." in namespace.ts(10,37+1)
You can’t perform that action at this time.
0 commit comments