@@ -2218,15 +2218,12 @@ namespace ts {
2218
2218
2219
2219
function fillSignature (
2220
2220
returnToken : SyntaxKind . ColonToken | SyntaxKind . EqualsGreaterThanToken ,
2221
- yieldContext : boolean ,
2222
- awaitContext : boolean ,
2223
- requireCompleteParameterList : boolean ,
2221
+ context : SignatureContext ,
2224
2222
signature : SignatureDeclaration ) : void {
2225
-
2226
- const returnTokenRequired = returnToken === SyntaxKind . EqualsGreaterThanToken ;
2227
2223
signature . typeParameters = parseTypeParameters ( ) ;
2228
- signature . parameters = parseParameterList ( yieldContext , awaitContext , requireCompleteParameterList ) ;
2224
+ signature . parameters = parseParameterList ( context ) ;
2229
2225
2226
+ const returnTokenRequired = returnToken === SyntaxKind . EqualsGreaterThanToken ;
2230
2227
if ( returnTokenRequired ) {
2231
2228
parseExpected ( returnToken ) ;
2232
2229
signature . type = parseTypeOrTypePredicate ( ) ;
@@ -2236,7 +2233,7 @@ namespace ts {
2236
2233
}
2237
2234
}
2238
2235
2239
- function parseParameterList ( yieldContext : boolean , awaitContext : boolean , requireCompleteParameterList : boolean ) {
2236
+ function parseParameterList ( context : SignatureContext ) {
2240
2237
// FormalParameters [Yield,Await]: (modified)
2241
2238
// [empty]
2242
2239
// FormalParameterList[?Yield,Await]
@@ -2254,15 +2251,15 @@ namespace ts {
2254
2251
const savedYieldContext = inYieldContext ( ) ;
2255
2252
const savedAwaitContext = inAwaitContext ( ) ;
2256
2253
2257
- setYieldContext ( yieldContext ) ;
2258
- setAwaitContext ( awaitContext ) ;
2254
+ setYieldContext ( ! ! ( context & SignatureContext . Yield ) ) ;
2255
+ setAwaitContext ( ! ! ( context & SignatureContext . Await ) ) ;
2259
2256
2260
2257
const result = parseDelimitedList ( ParsingContext . Parameters , parseParameter ) ;
2261
2258
2262
2259
setYieldContext ( savedYieldContext ) ;
2263
2260
setAwaitContext ( savedAwaitContext ) ;
2264
2261
2265
- if ( ! parseExpected ( SyntaxKind . CloseParenToken ) && requireCompleteParameterList ) {
2262
+ if ( ! parseExpected ( SyntaxKind . CloseParenToken ) && ( context & SignatureContext . RequireCompleteParameterList ) ) {
2266
2263
// Caller insisted that we had to end with a ) We didn't. So just return
2267
2264
// undefined here.
2268
2265
return undefined ;
@@ -2274,7 +2271,7 @@ namespace ts {
2274
2271
// We didn't even have an open paren. If the caller requires a complete parameter list,
2275
2272
// we definitely can't provide that. However, if they're ok with an incomplete one,
2276
2273
// then just return an empty set of parameters.
2277
- return requireCompleteParameterList ? undefined : createMissingList < ParameterDeclaration > ( ) ;
2274
+ return ( context & SignatureContext . RequireCompleteParameterList ) ? undefined : createMissingList < ParameterDeclaration > ( ) ;
2278
2275
}
2279
2276
2280
2277
function parseTypeMemberSemicolon ( ) {
@@ -2293,7 +2290,7 @@ namespace ts {
2293
2290
if ( kind === SyntaxKind . ConstructSignature ) {
2294
2291
parseExpected ( SyntaxKind . NewKeyword ) ;
2295
2292
}
2296
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ false , /*awaitContext*/ false , /*requireCompleteParameterList*/ false , node ) ;
2293
+ fillSignature ( SyntaxKind . ColonToken , SignatureContext . Type , node ) ;
2297
2294
parseTypeMemberSemicolon ( ) ;
2298
2295
return addJSDocComment ( finishNode ( node ) ) ;
2299
2296
}
@@ -2383,7 +2380,7 @@ namespace ts {
2383
2380
2384
2381
// Method signatures don't exist in expression contexts. So they have neither
2385
2382
// [Yield] nor [Await]
2386
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ false , /*awaitContext*/ false , /*requireCompleteParameterList*/ false , method ) ;
2383
+ fillSignature ( SyntaxKind . ColonToken , SignatureContext . Type , method ) ;
2387
2384
parseTypeMemberSemicolon ( ) ;
2388
2385
return addJSDocComment ( finishNode ( method ) ) ;
2389
2386
}
@@ -2527,7 +2524,7 @@ namespace ts {
2527
2524
if ( kind === SyntaxKind . ConstructorType ) {
2528
2525
parseExpected ( SyntaxKind . NewKeyword ) ;
2529
2526
}
2530
- fillSignature ( SyntaxKind . EqualsGreaterThanToken , /*yieldContext*/ false , /*awaitContext*/ false , /*requireCompleteParameterList*/ false , node ) ;
2527
+ fillSignature ( SyntaxKind . EqualsGreaterThanToken , SignatureContext . Type , node ) ;
2531
2528
return finishNode ( node ) ;
2532
2529
}
2533
2530
@@ -3254,7 +3251,7 @@ namespace ts {
3254
3251
function parseParenthesizedArrowFunctionExpressionHead ( allowAmbiguity : boolean ) : ArrowFunction {
3255
3252
const node = < ArrowFunction > createNode ( SyntaxKind . ArrowFunction ) ;
3256
3253
node . modifiers = parseModifiersForArrowFunction ( ) ;
3257
- const isAsync = ! ! ( getModifierFlags ( node ) & ModifierFlags . Async ) ;
3254
+ const isAsync = ( getModifierFlags ( node ) & ModifierFlags . Async ) ? SignatureContext . Await : 0 ;
3258
3255
3259
3256
// Arrow functions are never generators.
3260
3257
//
@@ -3263,7 +3260,7 @@ namespace ts {
3263
3260
// a => (b => c)
3264
3261
// And think that "(b =>" was actually a parenthesized arrow function with a missing
3265
3262
// close paren.
3266
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ false , /*awaitContext*/ isAsync , /*requireCompleteParameterList*/ ! allowAmbiguity , node ) ;
3263
+ fillSignature ( SyntaxKind . ColonToken , isAsync | ( allowAmbiguity ? 0 : SignatureContext . RequireCompleteParameterList ) , node ) ;
3267
3264
3268
3265
// If we couldn't get parameters, we definitely could not parse out an arrow function.
3269
3266
if ( ! node . parameters ) {
@@ -4386,16 +4383,16 @@ namespace ts {
4386
4383
parseExpected ( SyntaxKind . FunctionKeyword ) ;
4387
4384
node . asteriskToken = parseOptionalToken ( SyntaxKind . AsteriskToken ) ;
4388
4385
4389
- const isGenerator = ! ! node . asteriskToken ;
4390
- const isAsync = ! ! ( getModifierFlags ( node ) & ModifierFlags . Async ) ;
4386
+ const isGenerator = node . asteriskToken ? SignatureContext . Yield : 0 ;
4387
+ const isAsync = ( getModifierFlags ( node ) & ModifierFlags . Async ) ? SignatureContext . Await : 0 ;
4391
4388
node . name =
4392
4389
isGenerator && isAsync ? doInYieldAndAwaitContext ( parseOptionalIdentifier ) :
4393
4390
isGenerator ? doInYieldContext ( parseOptionalIdentifier ) :
4394
4391
isAsync ? doInAwaitContext ( parseOptionalIdentifier ) :
4395
4392
parseOptionalIdentifier ( ) ;
4396
4393
4397
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ isGenerator , /*awaitContext*/ isAsync , /*requireCompleteParameterList*/ false , node ) ;
4398
- node . body = parseFunctionBlock ( /*allowYield*/ isGenerator , /*allowAwait*/ isAsync , /*ignoreMissingOpenBrace*/ false ) ;
4394
+ fillSignature ( SyntaxKind . ColonToken , isGenerator | isAsync , node ) ;
4395
+ node . body = parseFunctionBlock ( /*allowYield*/ ! ! isGenerator , /*allowAwait*/ ! ! isAsync , /*ignoreMissingOpenBrace*/ false ) ;
4399
4396
4400
4397
if ( saveDecoratorContext ) {
4401
4398
setDecoratorContext ( /*val*/ true ) ;
@@ -5146,10 +5143,10 @@ namespace ts {
5146
5143
parseExpected ( SyntaxKind . FunctionKeyword ) ;
5147
5144
node . asteriskToken = parseOptionalToken ( SyntaxKind . AsteriskToken ) ;
5148
5145
node . name = hasModifier ( node , ModifierFlags . Default ) ? parseOptionalIdentifier ( ) : parseIdentifier ( ) ;
5149
- const isGenerator = ! ! node . asteriskToken ;
5150
- const isAsync = hasModifier ( node , ModifierFlags . Async ) ;
5151
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ isGenerator , /*awaitContext*/ isAsync , /*requireCompleteParameterList*/ false , node ) ;
5152
- node . body = parseFunctionBlockOrSemicolon ( isGenerator , isAsync , Diagnostics . or_expected ) ;
5146
+ const isGenerator = node . asteriskToken ? SignatureContext . Yield : 0 ;
5147
+ const isAsync = hasModifier ( node , ModifierFlags . Async ) ? SignatureContext . Await : 0 ;
5148
+ fillSignature ( SyntaxKind . ColonToken , isGenerator | isAsync , node ) ;
5149
+ node . body = parseFunctionBlockOrSemicolon ( ! ! isGenerator , ! ! isAsync , Diagnostics . or_expected ) ;
5153
5150
return addJSDocComment ( finishNode ( node ) ) ;
5154
5151
}
5155
5152
@@ -5158,7 +5155,7 @@ namespace ts {
5158
5155
node . decorators = decorators ;
5159
5156
node . modifiers = modifiers ;
5160
5157
parseExpected ( SyntaxKind . ConstructorKeyword ) ;
5161
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext */ false , /*awaitContext*/ false , /*requireCompleteParameterList*/ false , node ) ;
5158
+ fillSignature ( SyntaxKind . ColonToken , /*context */ 0 , node ) ;
5162
5159
node . body = parseFunctionBlockOrSemicolon ( /*isGenerator*/ false , /*isAsync*/ false , Diagnostics . or_expected ) ;
5163
5160
return addJSDocComment ( finishNode ( node ) ) ;
5164
5161
}
@@ -5170,10 +5167,10 @@ namespace ts {
5170
5167
method . asteriskToken = asteriskToken ;
5171
5168
method . name = name ;
5172
5169
method . questionToken = questionToken ;
5173
- const isGenerator = ! ! asteriskToken ;
5174
- const isAsync = hasModifier ( method , ModifierFlags . Async ) ;
5175
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext*/ isGenerator , /*awaitContext*/ isAsync , /*requireCompleteParameterList*/ false , method ) ;
5176
- method . body = parseFunctionBlockOrSemicolon ( isGenerator , isAsync , diagnosticMessage ) ;
5170
+ const isGenerator = asteriskToken ? SignatureContext . Yield : 0 ;
5171
+ const isAsync = hasModifier ( method , ModifierFlags . Async ) ? SignatureContext . Await : 0 ;
5172
+ fillSignature ( SyntaxKind . ColonToken , isGenerator | isAsync , method ) ;
5173
+ method . body = parseFunctionBlockOrSemicolon ( ! ! isGenerator , ! ! isAsync , diagnosticMessage ) ;
5177
5174
return addJSDocComment ( finishNode ( method ) ) ;
5178
5175
}
5179
5176
@@ -5226,7 +5223,7 @@ namespace ts {
5226
5223
node . decorators = decorators ;
5227
5224
node . modifiers = modifiers ;
5228
5225
node . name = parsePropertyName ( ) ;
5229
- fillSignature ( SyntaxKind . ColonToken , /*yieldContext */ false , /*awaitContext*/ false , /*requireCompleteParameterList*/ false , node ) ;
5226
+ fillSignature ( SyntaxKind . ColonToken , /*context */ 0 , node ) ;
5230
5227
node . body = parseFunctionBlockOrSemicolon ( /*isGenerator*/ false , /*isAsync*/ false ) ;
5231
5228
return addJSDocComment ( finishNode ( node ) ) ;
5232
5229
}
0 commit comments