From 7c01840b7dea71294051982d651275e45f22c125 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 10 Dec 2020 17:26:21 -0800 Subject: [PATCH] Move option under 'strict'. --- src/compiler/checker.ts | 3 ++- src/compiler/utilities.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c81958ed696..d7c552f55c6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -354,6 +354,7 @@ namespace ts { const strictPropertyInitialization = getStrictOptionValue(compilerOptions, "strictPropertyInitialization"); const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny"); const noImplicitThis = getStrictOptionValue(compilerOptions, "noImplicitThis"); + const useUnknownInCatchVariables = getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); const keyofStringsOnly = !!compilerOptions.keyofStringsOnly; const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : ObjectFlags.FreshLiteral; @@ -8603,7 +8604,7 @@ namespace ts { const declaration = symbol.valueDeclaration; if (isCatchClauseVariableDeclarationOrBindingElement(declaration)) { const decl = declaration as VariableDeclaration; - if (!decl.type) return compilerOptions.useUnknownInCatchVariables ? unknownType : anyType; + if (!decl.type) return useUnknownInCatchVariables ? unknownType : anyType; const type = getTypeOfNode(decl.type); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type) || type === unknownType ? type : errorType; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 43f5e4aa8ea..dadc78f8943 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6002,6 +6002,7 @@ namespace ts { | "strictBindCallApply" | "strictPropertyInitialization" | "alwaysStrict" + | "useUnknownInCatchVariables" ; export function getStrictOptionValue(compilerOptions: CompilerOptions, flag: StrictOptionName): boolean {