Skip to content

Commit 3cc8892

Browse files
committed
Revert part of catch clause PR which broke other declarations
1 parent 832d2d3 commit 3cc8892

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27211,7 +27211,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2721127211
isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) ||
2721227212
node.kind === SyntaxKind.ModuleBlock ||
2721327213
node.kind === SyntaxKind.SourceFile ||
27214-
node.kind === SyntaxKind.CatchClause ||
2721527214
node.kind === SyntaxKind.PropertyDeclaration)!;
2721627215
}
2721727216

@@ -27587,7 +27586,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2758727586
const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter;
2758827587
const declarationContainer = getControlFlowContainer(declaration);
2758927588
let flowContainer = getControlFlowContainer(node);
27590-
const isCatch = flowContainer.kind === SyntaxKind.CatchClause;
2759127589
const isOuterVariable = flowContainer !== declarationContainer;
2759227590
const isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
2759327591
const isModuleExports = symbol.flags & SymbolFlags.ModuleExports;
@@ -27602,7 +27600,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2760227600
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
2760327601
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
2760427602
// declaration container are the same).
27605-
const assumeInitialized = isParameter || isCatch || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
27603+
const assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
2760627604
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (TypeFlags.AnyOrUnknown | TypeFlags.Void)) !== 0 ||
2760727605
isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === SyntaxKind.ExportSpecifier) ||
2760827606
node.parent.kind === SyntaxKind.NonNullExpression ||

tests/baselines/reference/potentiallyUnassignedVariableInCatch.errors.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/baselines/reference/potentiallyUnassignedVariableInCatch.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ try {
1818
}
1919
} catch {
2020
foo;
21-
>foo : any
21+
>foo : number | undefined
2222
}
2323

0 commit comments

Comments
 (0)