@@ -4520,7 +4520,8 @@ module ts {
4520
4520
4521
4521
function parseImportDeclarationOrStatement ( fullStart : number , modifiers : ModifiersArray ) : ImportEqualsDeclaration | ImportStatement {
4522
4522
parseExpected ( SyntaxKind . ImportKeyword ) ;
4523
- if ( token === SyntaxKind . StringLiteral ) {
4523
+ if ( token === SyntaxKind . StringLiteral ||
4524
+ token === SyntaxKind . AsteriskToken ) {
4524
4525
return parseImportStatement ( fullStart , modifiers ) ;
4525
4526
}
4526
4527
@@ -4564,7 +4565,12 @@ module ts {
4564
4565
setModifiers ( node , modifiers ) ;
4565
4566
4566
4567
// ImportDeclaration:
4568
+ // import ImportClause ModuleSpecifier ;
4567
4569
// import ModuleSpecifier;
4570
+ if ( token !== SyntaxKind . StringLiteral ) {
4571
+ // ImportDeclaration:
4572
+ node . importClause = parseImportClause ( ) ;
4573
+ }
4568
4574
node . moduleSpecifier = parseModuleSpecifier ( ) ;
4569
4575
parseSemicolon ( ) ;
4570
4576
return finishNode ( node ) ;
@@ -4583,6 +4589,30 @@ module ts {
4583
4589
parseErrorAtCurrentToken ( Diagnostics . String_literal_expected ) ;
4584
4590
}
4585
4591
4592
+ function parseImportClause ( ) : ImportClause {
4593
+ //ImportClause:
4594
+ // ImportedDefaultBinding from
4595
+ // NameSpaceImport from
4596
+ // NamedImports from
4597
+ // ImportedDefaultBinding, NameSpaceImport from
4598
+ // ImportedDefaultBinding, NamedImports from
4599
+
4600
+ var importClause = < ImportClause > createNode ( SyntaxKind . ImportClause ) ;
4601
+ importClause . bindings = parseNamespaceImport ( ) ;
4602
+ parseExpected ( SyntaxKind . FromKeyword ) ;
4603
+ return finishNode ( importClause ) ;
4604
+ }
4605
+
4606
+ function parseNamespaceImport ( ) : NamespaceImport {
4607
+ // NameSpaceImport:
4608
+ // * as ImportedBinding
4609
+ var namespaceImport = < NamespaceImport > createNode ( SyntaxKind . NamespaceImport ) ;
4610
+ parseExpected ( SyntaxKind . AsteriskToken ) ;
4611
+ parseExpected ( SyntaxKind . AsKeyword ) ;
4612
+ namespaceImport . name = parseIdentifier ( ) ;
4613
+ return finishNode ( namespaceImport ) ;
4614
+ }
4615
+
4586
4616
function parseExportAssignmentTail ( fullStart : number , modifiers : ModifiersArray ) : ExportAssignment {
4587
4617
var node = < ExportAssignment > createNode ( SyntaxKind . ExportAssignment , fullStart ) ;
4588
4618
setModifiers ( node , modifiers ) ;
@@ -4612,6 +4642,8 @@ module ts {
4612
4642
// Not true keywords so ensure an identifier follows
4613
4643
return lookAhead ( nextTokenIsIdentifierOrKeyword ) ;
4614
4644
case SyntaxKind . ImportKeyword :
4645
+ // Not true keywords so ensure an identifier follows or is string literal or asterisk
4646
+ return lookAhead ( nextTokenIsIdentifierOrKeywordOrStringLiteralOrAsterisk ) ;
4615
4647
case SyntaxKind . ModuleKeyword :
4616
4648
// Not a true keyword so ensure an identifier or string literal follows
4617
4649
return lookAhead ( nextTokenIsIdentifierOrKeywordOrStringLiteral ) ;
@@ -4642,6 +4674,12 @@ module ts {
4642
4674
return isIdentifierOrKeyword ( ) || token === SyntaxKind . StringLiteral ;
4643
4675
}
4644
4676
4677
+ function nextTokenIsIdentifierOrKeywordOrStringLiteralOrAsterisk ( ) {
4678
+ nextToken ( ) ;
4679
+ return isIdentifierOrKeyword ( ) || token === SyntaxKind . StringLiteral ||
4680
+ token === SyntaxKind . AsteriskToken ;
4681
+ }
4682
+
4645
4683
function nextTokenIsEqualsTokenOrDeclarationStart ( ) {
4646
4684
nextToken ( ) ;
4647
4685
return token === SyntaxKind . EqualsToken || isDeclarationStart ( ) ;
0 commit comments