@@ -3704,6 +3704,7 @@ module ts {
3704
3704
return ! isConstEnum ;
3705
3705
case SyntaxKind . InterfaceKeyword :
3706
3706
case SyntaxKind . ModuleKeyword :
3707
+ case SyntaxKind . NamespaceKeyword :
3707
3708
case SyntaxKind . EnumKeyword :
3708
3709
case SyntaxKind . TypeKeyword :
3709
3710
// When followed by an identifier, these do not start a statement but might
@@ -4371,14 +4372,14 @@ module ts {
4371
4372
return finishNode ( node ) ;
4372
4373
}
4373
4374
4374
- function parseInternalModuleTail ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : ModifiersArray , flags : NodeFlags ) : ModuleDeclaration {
4375
+ function parseModuleOrNamespaceDeclaration ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : ModifiersArray , flags : NodeFlags ) : ModuleDeclaration {
4375
4376
let node = < ModuleDeclaration > createNode ( SyntaxKind . ModuleDeclaration , fullStart ) ;
4376
4377
node . decorators = decorators ;
4377
4378
setModifiers ( node , modifiers ) ;
4378
4379
node . flags |= flags ;
4379
4380
node . name = parseIdentifier ( ) ;
4380
4381
node . body = parseOptional ( SyntaxKind . DotToken )
4381
- ? parseInternalModuleTail ( getNodePos ( ) , /*decorators*/ undefined , /*modifiers:*/ undefined , NodeFlags . Export )
4382
+ ? parseModuleOrNamespaceDeclaration ( getNodePos ( ) , /*decorators*/ undefined , /*modifiers:*/ undefined , NodeFlags . Export )
4382
4383
: parseModuleBlock ( ) ;
4383
4384
return finishNode ( node ) ;
4384
4385
}
@@ -4393,10 +4394,17 @@ module ts {
4393
4394
}
4394
4395
4395
4396
function parseModuleDeclaration ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : ModifiersArray ) : ModuleDeclaration {
4396
- parseExpected ( SyntaxKind . ModuleKeyword ) ;
4397
- return token === SyntaxKind . StringLiteral
4398
- ? parseAmbientExternalModuleDeclaration ( fullStart , decorators , modifiers )
4399
- : parseInternalModuleTail ( fullStart , decorators , modifiers , modifiers ? modifiers . flags : 0 ) ;
4397
+ let flags = modifiers ? modifiers . flags : 0 ;
4398
+ if ( parseOptional ( SyntaxKind . NamespaceKeyword ) ) {
4399
+ flags |= NodeFlags . Namespace ;
4400
+ }
4401
+ else {
4402
+ parseExpected ( SyntaxKind . ModuleKeyword ) ;
4403
+ if ( token === SyntaxKind . StringLiteral ) {
4404
+ return parseAmbientExternalModuleDeclaration ( fullStart , decorators , modifiers ) ;
4405
+ }
4406
+ }
4407
+ return parseModuleOrNamespaceDeclaration ( fullStart , decorators , modifiers , flags ) ;
4400
4408
}
4401
4409
4402
4410
function isExternalModuleReference ( ) {
@@ -4631,6 +4639,7 @@ module ts {
4631
4639
// Not true keywords so ensure an identifier follows or is string literal or asterisk or open brace
4632
4640
return lookAhead ( nextTokenCanFollowImportKeyword ) ;
4633
4641
case SyntaxKind . ModuleKeyword :
4642
+ case SyntaxKind . NamespaceKeyword :
4634
4643
// Not a true keyword so ensure an identifier or string literal follows
4635
4644
return lookAhead ( nextTokenIsIdentifierOrKeywordOrStringLiteral ) ;
4636
4645
case SyntaxKind . ExportKeyword :
@@ -4715,6 +4724,7 @@ module ts {
4715
4724
case SyntaxKind . EnumKeyword :
4716
4725
return parseEnumDeclaration ( fullStart , decorators , modifiers ) ;
4717
4726
case SyntaxKind . ModuleKeyword :
4727
+ case SyntaxKind . NamespaceKeyword :
4718
4728
return parseModuleDeclaration ( fullStart , decorators , modifiers ) ;
4719
4729
case SyntaxKind . ImportKeyword :
4720
4730
return parseImportDeclarationOrImportEqualsDeclaration ( fullStart , decorators , modifiers ) ;
0 commit comments