File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 194194 "Cannot extend a class '{0}'. Class constructor is marked as private." : 2675 ,
195195 "The 'this' types of each signature are incompatible." : 2685 ,
196196 "Namespace '{0}' has no exported member '{1}'." : 2694 ,
197+ "Namespace can only have declarations." : 2695 ,
197198 "Required type parameters may not follow optional type parameters." : 2706 ,
198199 "Duplicate property '{0}'." : 2718 ,
199200 "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 {
398398 tn . range ( declareStart , declareEnd ) , "declare"
399399 ) ; // recoverable
400400 }
401- if ( ! namespace ) {
401+ if ( namespace ) {
402+ this . error (
403+ DiagnosticCode . Namespace_can_only_have_declarations ,
404+ tn . range ( startPos )
405+ ) ;
406+ } else {
402407 statement = this . parseStatement ( tn , true ) ;
403- } // TODO: else?
408+ }
404409 }
405410 break ;
406411 }
Original file line number Diff line number Diff line change 1+ let outerVar :i32 = 0 ;
12declare namespace A {
23 namespace B {
34 export namespace C {
45 var aVar : i32 ;
6+ outerVar = 42 ; // 2695: Namespace can only have declarations.
57 const aConst : i32 ;
68 const aConstInvalid : i32 = 0 ; // 1039: Initializers are not allowed in ambient contexts.
79 function aFunc ( ) : void ;
Original file line number Diff line number Diff line change 1+ let outerVar : i32 = 0 ;
12declare namespace A {
23 namespace B {
34 export namespace C {
@@ -14,5 +15,6 @@ declare namespace A {
1415 }
1516 }
1617}
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