@@ -1309,7 +1309,7 @@ namespace ts {
1309
1309
case ParsingContext . ObjectBindingElements :
1310
1310
return token ( ) === SyntaxKind . OpenBracketToken || token ( ) === SyntaxKind . DotDotDotToken || isLiteralPropertyName ( ) ;
1311
1311
case ParsingContext . HeritageClauseElement :
1312
- // If we see { } then only consume it as an expression if it is followed by , or {
1312
+ // If we see { } then only consume it as an expression if it is followed by `,` or `{`
1313
1313
// That way we won't consume the body of a class in its heritage clause.
1314
1314
if ( token ( ) === SyntaxKind . OpenBraceToken ) {
1315
1315
return lookAhead ( isValidHeritageClauseObjectLiteral ) ;
@@ -2113,7 +2113,7 @@ namespace ts {
2113
2113
return finishNode ( node ) ;
2114
2114
}
2115
2115
2116
- function parseTypeParameters ( ) : NodeArray < TypeParameterDeclaration > {
2116
+ function parseTypeParameters ( ) : NodeArray < TypeParameterDeclaration > | undefined {
2117
2117
if ( token ( ) === SyntaxKind . LessThanToken ) {
2118
2118
return parseBracketedList ( ParsingContext . TypeParameters , parseTypeParameter , SyntaxKind . LessThanToken , SyntaxKind . GreaterThanToken ) ;
2119
2119
}
@@ -2183,7 +2183,7 @@ namespace ts {
2183
2183
}
2184
2184
2185
2185
function fillSignature (
2186
- returnToken : SyntaxKind ,
2186
+ returnToken : SyntaxKind . ColonToken | SyntaxKind . EqualsGreaterThanToken ,
2187
2187
yieldContext : boolean ,
2188
2188
awaitContext : boolean ,
2189
2189
requireCompleteParameterList : boolean ,
@@ -2373,14 +2373,14 @@ namespace ts {
2373
2373
}
2374
2374
2375
2375
function isTypeMemberStart ( ) : boolean {
2376
- let idToken : SyntaxKind ;
2377
2376
// Return true if we have the start of a signature member
2378
2377
if ( token ( ) === SyntaxKind . OpenParenToken || token ( ) === SyntaxKind . LessThanToken ) {
2379
2378
return true ;
2380
2379
}
2380
+ let idToken : boolean ;
2381
2381
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier
2382
2382
while ( isModifierKind ( token ( ) ) ) {
2383
- idToken = token ( ) ;
2383
+ idToken = true ;
2384
2384
nextToken ( ) ;
2385
2385
}
2386
2386
// Index signatures and computed property names are type members
@@ -2389,7 +2389,7 @@ namespace ts {
2389
2389
}
2390
2390
// Try to get the first property-like token following all modifiers
2391
2391
if ( isLiteralPropertyName ( ) ) {
2392
- idToken = token ( ) ;
2392
+ idToken = true ;
2393
2393
nextToken ( ) ;
2394
2394
}
2395
2395
// If we were able to get any potential identifier, check that it is
@@ -2497,7 +2497,7 @@ namespace ts {
2497
2497
return finishNode ( node ) ;
2498
2498
}
2499
2499
2500
- function parseKeywordAndNoDot ( ) : TypeNode {
2500
+ function parseKeywordAndNoDot ( ) : TypeNode | undefined {
2501
2501
const node = parseTokenNode < TypeNode > ( ) ;
2502
2502
return token ( ) === SyntaxKind . DotToken ? undefined : node ;
2503
2503
}
@@ -2635,7 +2635,7 @@ namespace ts {
2635
2635
return parseArrayTypeOrHigher ( ) ;
2636
2636
}
2637
2637
2638
- function parseUnionOrIntersectionType ( kind : SyntaxKind , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind ) : TypeNode {
2638
+ function parseUnionOrIntersectionType ( kind : SyntaxKind . UnionType | SyntaxKind . IntersectionType , parseConstituentType : ( ) => TypeNode , operator : SyntaxKind . BarToken | SyntaxKind . AmpersandToken ) : TypeNode {
2639
2639
parseOptional ( operator ) ;
2640
2640
let type = parseConstituentType ( ) ;
2641
2641
if ( token ( ) === operator ) {
@@ -5281,8 +5281,8 @@ namespace ts {
5281
5281
*
5282
5282
* In such situations, 'permitInvalidConstAsModifier' should be set to true.
5283
5283
*/
5284
- function parseModifiers ( permitInvalidConstAsModifier ?: boolean ) : NodeArray < Modifier > {
5285
- let modifiers : NodeArray < Modifier > ;
5284
+ function parseModifiers ( permitInvalidConstAsModifier ?: boolean ) : NodeArray < Modifier > | undefined {
5285
+ let modifiers : NodeArray < Modifier > | undefined ;
5286
5286
while ( true ) {
5287
5287
const modifierStart = scanner . getStartPos ( ) ;
5288
5288
const modifierKind = token ( ) ;
@@ -5422,7 +5422,7 @@ namespace ts {
5422
5422
return token ( ) === SyntaxKind . ImplementsKeyword && lookAhead ( nextTokenIsIdentifierOrKeyword ) ;
5423
5423
}
5424
5424
5425
- function parseHeritageClauses ( ) : NodeArray < HeritageClause > {
5425
+ function parseHeritageClauses ( ) : NodeArray < HeritageClause > | undefined {
5426
5426
// ClassTail[Yield,Await] : (Modified) See 14.5
5427
5427
// ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
5428
5428
@@ -5433,7 +5433,7 @@ namespace ts {
5433
5433
return undefined ;
5434
5434
}
5435
5435
5436
- function parseHeritageClause ( ) {
5436
+ function parseHeritageClause ( ) : HeritageClause | undefined {
5437
5437
if ( token ( ) === SyntaxKind . ExtendsKeyword || token ( ) === SyntaxKind . ImplementsKeyword ) {
5438
5438
const node = < HeritageClause > createNode ( SyntaxKind . HeritageClause ) ;
5439
5439
node . token = token ( ) ;
@@ -5459,7 +5459,7 @@ namespace ts {
5459
5459
return token ( ) === SyntaxKind . ExtendsKeyword || token ( ) === SyntaxKind . ImplementsKeyword ;
5460
5460
}
5461
5461
5462
- function parseClassMembers ( ) {
5462
+ function parseClassMembers ( ) : NodeArray < ClassElement > {
5463
5463
return parseList ( ParsingContext . ClassMembers , parseClassElement ) ;
5464
5464
}
5465
5465
@@ -5618,17 +5618,7 @@ namespace ts {
5618
5618
if ( isIdentifier ( ) ) {
5619
5619
identifier = parseIdentifier ( ) ;
5620
5620
if ( token ( ) !== SyntaxKind . CommaToken && token ( ) !== SyntaxKind . FromKeyword ) {
5621
- // ImportEquals declaration of type:
5622
- // import x = require("mod"); or
5623
- // import x = M.x;
5624
- const importEqualsDeclaration = < ImportEqualsDeclaration > createNode ( SyntaxKind . ImportEqualsDeclaration , fullStart ) ;
5625
- importEqualsDeclaration . decorators = decorators ;
5626
- importEqualsDeclaration . modifiers = modifiers ;
5627
- importEqualsDeclaration . name = identifier ;
5628
- parseExpected ( SyntaxKind . EqualsToken ) ;
5629
- importEqualsDeclaration . moduleReference = parseModuleReference ( ) ;
5630
- parseSemicolon ( ) ;
5631
- return addJSDocComment ( finishNode ( importEqualsDeclaration ) ) ;
5621
+ return parseImportEqualsDeclaration ( fullStart , decorators , modifiers , identifier ) ;
5632
5622
}
5633
5623
}
5634
5624
@@ -5652,6 +5642,20 @@ namespace ts {
5652
5642
return finishNode ( importDeclaration ) ;
5653
5643
}
5654
5644
5645
+ function parseImportEqualsDeclaration ( fullStart : number , decorators : NodeArray < Decorator > , modifiers : NodeArray < Modifier > , identifier : ts . Identifier ) : ImportEqualsDeclaration {
5646
+ // ImportEquals declaration of type:
5647
+ // import x = require("mod"); or
5648
+ // import x = M.x;
5649
+ const importEqualsDeclaration = < ImportEqualsDeclaration > createNode ( SyntaxKind . ImportEqualsDeclaration , fullStart ) ;
5650
+ importEqualsDeclaration . decorators = decorators ;
5651
+ importEqualsDeclaration . modifiers = modifiers ;
5652
+ importEqualsDeclaration . name = identifier ;
5653
+ parseExpected ( SyntaxKind . EqualsToken ) ;
5654
+ importEqualsDeclaration . moduleReference = parseModuleReference ( ) ;
5655
+ parseSemicolon ( ) ;
5656
+ return addJSDocComment ( finishNode ( importEqualsDeclaration ) ) ;
5657
+ }
5658
+
5655
5659
function parseImportClause ( identifier : Identifier , fullStart : number ) {
5656
5660
// ImportClause:
5657
5661
// ImportedDefaultBinding
0 commit comments