Skip to content

Commit 516267c

Browse files
committed
Fix error in tsserver with semantic tokens enabled; needs test
1 parent 8ba18fd commit 516267c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27074,6 +27074,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2707427074
isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) ||
2707527075
node.kind === SyntaxKind.ModuleBlock ||
2707627076
node.kind === SyntaxKind.SourceFile ||
27077+
node.kind === SyntaxKind.CatchClause ||
2707727078
node.kind === SyntaxKind.PropertyDeclaration)!;
2707827079
}
2707927080

@@ -27446,6 +27447,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2744627447
const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter;
2744727448
const declarationContainer = getControlFlowContainer(declaration);
2744827449
let flowContainer = getControlFlowContainer(node);
27450+
const isCatch = flowContainer.kind === SyntaxKind.CatchClause;
2744927451
const isOuterVariable = flowContainer !== declarationContainer;
2745027452
const isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
2745127453
const isModuleExports = symbol.flags & SymbolFlags.ModuleExports;
@@ -27460,7 +27462,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2746027462
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
2746127463
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
2746227464
// declaration container are the same).
27463-
const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
27465+
const assumeInitialized = isParameter || isCatch || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
2746427466
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.Void)) !== 0 ||
2746527467
isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === SyntaxKind.ExportSpecifier) ||
2746627468
node.parent.kind === SyntaxKind.NonNullExpression ||

0 commit comments

Comments
 (0)