(
base: N.Expression,
startLoc: Position,
noCalls: boolean | undefined | null,
subscriptState: N.ParseSubscriptState,
)
| 3336 | } |
| 3337 | |
| 3338 | parseSubscript( |
| 3339 | base: N.Expression, |
| 3340 | startLoc: Position, |
| 3341 | noCalls: boolean | undefined | null, |
| 3342 | subscriptState: N.ParseSubscriptState, |
| 3343 | ): N.Expression { |
| 3344 | if (this.match(tt.questionDot) && this.isLookaheadToken_lt()) { |
| 3345 | subscriptState.optionalChainMember = true; |
| 3346 | if (noCalls) { |
| 3347 | subscriptState.stop = true; |
| 3348 | return base; |
| 3349 | } |
| 3350 | this.next(); |
| 3351 | const node = this.startNodeAt<N.OptionalCallExpression>(startLoc); |
| 3352 | node.callee = base; |
| 3353 | node.typeArguments = |
| 3354 | this.flowParseTypeParameterInstantiationInExpression(); |
| 3355 | this.expect(tt.parenL); |
| 3356 | node.arguments = this.parseCallExpressionArguments(); |
| 3357 | node.optional = true; |
| 3358 | return this.finishCallExpression(node, /* optional */ true); |
| 3359 | } else if ( |
| 3360 | !noCalls && |
| 3361 | this.shouldParseTypes() && |
| 3362 | (this.match(tt.lt) || |
| 3363 | // also handles `new C<<T>` |
| 3364 | this.match(tt.bitShiftL)) |
| 3365 | ) { |
| 3366 | const node = this.startNodeAt< |
| 3367 | N.OptionalCallExpression | N.CallExpression |
| 3368 | >(startLoc); |
| 3369 | node.callee = base; |
| 3370 | |
| 3371 | const result = this.tryParse(() => { |
| 3372 | node.typeArguments = |
| 3373 | this.flowParseTypeParameterInstantiationCallOrNew(); |
| 3374 | this.expect(tt.parenL); |
| 3375 | node.arguments = super.parseCallExpressionArguments(); |
| 3376 | if (subscriptState.optionalChainMember) { |
| 3377 | (node as Undone<N.OptionalCallExpression>).optional = false; |
| 3378 | } |
| 3379 | return this.finishCallExpression( |
| 3380 | node, |
| 3381 | subscriptState.optionalChainMember, |
| 3382 | ); |
| 3383 | }); |
| 3384 | |
| 3385 | if (result.node) { |
| 3386 | if (result.error) this.state = result.failState; |
| 3387 | return result.node; |
| 3388 | } |
| 3389 | } |
| 3390 | |
| 3391 | return super.parseSubscript(base, startLoc, noCalls, subscriptState); |
| 3392 | } |
| 3393 | |
| 3394 | parseNewCallee(node: N.NewExpression): void { |
| 3395 | super.parseNewCallee(node); |
no test coverage detected