Skip to content

Commit

Permalink
refactor: enable useUnknownInCatchVariables compiler option (#24215)
Browse files Browse the repository at this point in the history
Enables the `useUnknownInCatchVariables` compiler option and fixes a couple of errors.

(cherry picked from commit 667a555)
  • Loading branch information
crisbeto authored and andrewseguin committed Jan 17, 2022
1 parent e917a91 commit a413e30
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/bazel-tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"noImplicitReturns": true,
"strictFunctionTypes": true,
"noImplicitOverride": true,
"useUnknownInCatchVariables": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitThis": true,
Expand Down
1 change: 1 addition & 0 deletions src/cdk/schematics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"outDir": "../../../dist/packages/cdk/schematics",
"noEmitOnError": false,
"strictNullChecks": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitAny": true,
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/schematics/utils/project-tsconfig-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function getWorkspaceConfigGracefully(
return await readJsonWorkspace(path, {
readFile: async filePath => tree.read(filePath)!.toString(),
} as WorkspaceHost);
} catch (e) {
} catch {
return null;
}
}
14 changes: 7 additions & 7 deletions src/cdk/testing/tests/cross-environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function crossEnvironmentSpecs(
await loader.getChildLoader('error');
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(HarnessLoader for element matching selector: "error")',
);
Expand All @@ -82,7 +82,7 @@ export function crossEnvironmentSpecs(
await countersLoader.getHarness(SubComponentHarness);
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(SubComponentHarness with host element matching selector: "test-sub")',
);
Expand Down Expand Up @@ -112,7 +112,7 @@ export function crossEnvironmentSpecs(
await harness.errorItem();
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(TestElement for element matching selector: "wrong locator")',
);
Expand Down Expand Up @@ -147,7 +147,7 @@ export function crossEnvironmentSpecs(
await harness.errorSubComponent();
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(WrongComponentHarness with host element matching selector: "wrong-selector")',
);
Expand Down Expand Up @@ -211,7 +211,7 @@ export function crossEnvironmentSpecs(
await harness.requiredAncestorRestrictedMissingSubcomponent();
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(SubComponentHarness with host element matching selector: "test-sub"' +
' satisfying the constraints: has ancestor matching selector ".not-found")',
Expand Down Expand Up @@ -311,7 +311,7 @@ export function crossEnvironmentSpecs(
await harness.requiredFourIteamToolsLists();
fail('Expected to throw');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(SubComponentHarness with host element matching selector: "test-sub" satisfying' +
' the constraints: title = "List of test tools", item count = 4)',
Expand Down Expand Up @@ -640,7 +640,7 @@ export function crossEnvironmentSpecs(
await harness.missingElementsAndHarnesses();
fail('Expected to throw.');
} catch (e) {
expect(e.message).toBe(
expect((e as Error).message).toBe(
'Failed to find element matching one of the following queries:' +
'\n(TestElement for element matching selector: ".not-found"),' +
'\n(SubComponentHarness with host element matching selector: "test-sub" satisfying' +
Expand Down
1 change: 1 addition & 0 deletions src/material/schematics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"outDir": "../../../dist/packages/material/schematics",
"noEmitOnError": false,
"strictNullChecks": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"noImplicitAny": true,
"noFallthroughCasesInSwitch": true,
Expand Down
1 change: 1 addition & 0 deletions tools/dgeni/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"moduleResolution": "node",
"esModuleInterop": true,
"strictNullChecks": true,
"useUnknownInCatchVariables": true,
"noImplicitReturns": true,
"strictFunctionTypes": true,
"noImplicitThis": true,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": false,
"strictNullChecks": true,
"useUnknownInCatchVariables": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"strictFunctionTypes": true,
Expand Down

0 comments on commit a413e30

Please sign in to comment.