@@ -4527,6 +4527,8 @@ module ts {
4527
4527
4528
4528
function parseImportDeclarationOrImportEqualsDeclaration ( fullStart : number , modifiers : ModifiersArray ) : ImportEqualsDeclaration | ImportDeclaration {
4529
4529
parseExpected ( SyntaxKind . ImportKeyword ) ;
4530
+ var afterImportPos = scanner . getStartPos ( ) ;
4531
+
4530
4532
var identifier : Identifier ;
4531
4533
if ( isIdentifier ( ) ) {
4532
4534
identifier = parseIdentifier ( ) ;
@@ -4554,28 +4556,7 @@ module ts {
4554
4556
if ( identifier || // import id
4555
4557
token === SyntaxKind . AsteriskToken || // import *
4556
4558
token === SyntaxKind . OpenBraceToken ) { // import {
4557
- //ImportClause:
4558
- // ImportedDefaultBinding
4559
- // NameSpaceImport
4560
- // NamedImports
4561
- // ImportedDefaultBinding, NameSpaceImport
4562
- // ImportedDefaultBinding, NamedImports
4563
-
4564
- var importClause = < ImportClause > createNode ( SyntaxKind . ImportClause ) ;
4565
- if ( identifier ) {
4566
- // ImportedDefaultBinding:
4567
- // ImportedBinding
4568
- importClause . name = identifier ;
4569
- }
4570
-
4571
- // If there was no default import or if there is comma token after default import
4572
- // parse namespace or named imports
4573
- if ( ! importClause . name ||
4574
- parseOptional ( SyntaxKind . CommaToken ) ) {
4575
- importClause . namedBindings = token === SyntaxKind . AsteriskToken ? parseNamespaceImport ( ) : parseNamedImports ( ) ;
4576
- }
4577
-
4578
- importDeclaration . importClause = finishNode ( importClause ) ;
4559
+ importDeclaration . importClause = parseImportClause ( identifier , afterImportPos ) ;
4579
4560
parseExpected ( SyntaxKind . FromKeyword ) ;
4580
4561
}
4581
4562
@@ -4584,6 +4565,31 @@ module ts {
4584
4565
return finishNode ( importDeclaration ) ;
4585
4566
}
4586
4567
4568
+ function parseImportClause ( identifier : Identifier , fullStart : number ) {
4569
+ //ImportClause:
4570
+ // ImportedDefaultBinding
4571
+ // NameSpaceImport
4572
+ // NamedImports
4573
+ // ImportedDefaultBinding, NameSpaceImport
4574
+ // ImportedDefaultBinding, NamedImports
4575
+
4576
+ var importClause = < ImportClause > createNode ( SyntaxKind . ImportClause , fullStart ) ;
4577
+ if ( identifier ) {
4578
+ // ImportedDefaultBinding:
4579
+ // ImportedBinding
4580
+ importClause . name = identifier ;
4581
+ }
4582
+
4583
+ // If there was no default import or if there is comma token after default import
4584
+ // parse namespace or named imports
4585
+ if ( ! importClause . name ||
4586
+ parseOptional ( SyntaxKind . CommaToken ) ) {
4587
+ importClause . namedBindings = token === SyntaxKind . AsteriskToken ? parseNamespaceImport ( ) : parseNamedImports ( ) ;
4588
+ }
4589
+
4590
+ return finishNode ( importClause ) ;
4591
+ }
4592
+
4587
4593
function parseModuleReference ( ) {
4588
4594
return isExternalModuleReference ( )
4589
4595
? parseExternalModuleReference ( )
0 commit comments