Skip to content

Commit c52b129

Browse files
committed
Add cancellation token check for function expression, arrow expression and class expression just like their counter part declarations
This helps in early exit if request is cancelled and intellisense in js files is super quick with edits
1 parent a35f799 commit c52b129

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/compiler/checker.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -25271,7 +25271,18 @@ namespace ts {
2527125271
}
2527225272

2527325273
function checkExpressionWorker(node: Expression | QualifiedName, checkMode: CheckMode | undefined, forceTuple?: boolean): Type {
25274-
switch (node.kind) {
25274+
const kind = node.kind;
25275+
if (cancellationToken) {
25276+
// Only bother checking on a few construct kinds. We don't want to be excessively
25277+
// hitting the cancellation token on every node we check.
25278+
switch (kind) {
25279+
case SyntaxKind.ClassExpression:
25280+
case SyntaxKind.FunctionExpression:
25281+
case SyntaxKind.ArrowFunction:
25282+
cancellationToken.throwIfCancellationRequested();
25283+
}
25284+
}
25285+
switch (kind) {
2527525286
case SyntaxKind.Identifier:
2527625287
return checkIdentifier(<Identifier>node);
2527725288
case SyntaxKind.ThisKeyword:

0 commit comments

Comments
 (0)