@@ -4520,7 +4520,8 @@ module ts {
45204520
45214521 function parseImportDeclarationOrStatement ( fullStart : number , modifiers : ModifiersArray ) : ImportEqualsDeclaration | ImportStatement {
45224522 parseExpected ( SyntaxKind . ImportKeyword ) ;
4523- if ( token === SyntaxKind . StringLiteral ) {
4523+ if ( token === SyntaxKind . StringLiteral ||
4524+ token === SyntaxKind . AsteriskToken ) {
45244525 return parseImportStatement ( fullStart , modifiers ) ;
45254526 }
45264527
@@ -4564,7 +4565,12 @@ module ts {
45644565 setModifiers ( node , modifiers ) ;
45654566
45664567 // ImportDeclaration:
4568+ // import ImportClause ModuleSpecifier ;
45674569 // import ModuleSpecifier;
4570+ if ( token !== SyntaxKind . StringLiteral ) {
4571+ // ImportDeclaration:
4572+ node . importClause = parseImportClause ( ) ;
4573+ }
45684574 node . moduleSpecifier = parseModuleSpecifier ( ) ;
45694575 parseSemicolon ( ) ;
45704576 return finishNode ( node ) ;
@@ -4583,6 +4589,30 @@ module ts {
45834589 parseErrorAtCurrentToken ( Diagnostics . String_literal_expected ) ;
45844590 }
45854591
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+
45864616 function parseExportAssignmentTail ( fullStart : number , modifiers : ModifiersArray ) : ExportAssignment {
45874617 var node = < ExportAssignment > createNode ( SyntaxKind . ExportAssignment , fullStart ) ;
45884618 setModifiers ( node , modifiers ) ;
@@ -4612,6 +4642,8 @@ module ts {
46124642 // Not true keywords so ensure an identifier follows
46134643 return lookAhead ( nextTokenIsIdentifierOrKeyword ) ;
46144644 case SyntaxKind . ImportKeyword :
4645+ // Not true keywords so ensure an identifier follows or is string literal or asterisk
4646+ return lookAhead ( nextTokenIsIdentifierOrKeywordOrStringLiteralOrAsterisk ) ;
46154647 case SyntaxKind . ModuleKeyword :
46164648 // Not a true keyword so ensure an identifier or string literal follows
46174649 return lookAhead ( nextTokenIsIdentifierOrKeywordOrStringLiteral ) ;
@@ -4642,6 +4674,12 @@ module ts {
46424674 return isIdentifierOrKeyword ( ) || token === SyntaxKind . StringLiteral ;
46434675 }
46444676
4677+ function nextTokenIsIdentifierOrKeywordOrStringLiteralOrAsterisk ( ) {
4678+ nextToken ( ) ;
4679+ return isIdentifierOrKeyword ( ) || token === SyntaxKind . StringLiteral ||
4680+ token === SyntaxKind . AsteriskToken ;
4681+ }
4682+
46454683 function nextTokenIsEqualsTokenOrDeclarationStart ( ) {
46464684 nextToken ( ) ;
46474685 return token === SyntaxKind . EqualsToken || isDeclarationStart ( ) ;
0 commit comments