Skip to content

Commit 667a555

Browse files
authored
refactor: enable useUnknownInCatchVariables compiler option (#24215)
Enables the `useUnknownInCatchVariables` compiler option and fixes a couple of errors.
1 parent f63d669 commit 667a555

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

src/bazel-tsconfig-build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"noImplicitReturns": true,
1616
"strictFunctionTypes": true,
1717
"noImplicitOverride": true,
18+
"useUnknownInCatchVariables": true,
1819
"noFallthroughCasesInSwitch": true,
1920
"noImplicitAny": true,
2021
"noImplicitThis": true,

src/cdk/schematics/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"outDir": "../../../dist/packages/cdk/schematics",
88
"noEmitOnError": false,
99
"strictNullChecks": true,
10+
"useUnknownInCatchVariables": true,
1011
"noImplicitOverride": true,
1112
"noImplicitReturns": true,
1213
"noImplicitAny": true,

src/cdk/schematics/utils/project-tsconfig-paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function getWorkspaceConfigGracefully(
4343
return await readJsonWorkspace(path, {
4444
readFile: async filePath => tree.read(filePath)!.toString(),
4545
} as WorkspaceHost);
46-
} catch (e) {
46+
} catch {
4747
return null;
4848
}
4949
}

src/cdk/testing/tests/cross-environment.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function crossEnvironmentSpecs(
5858
await loader.getChildLoader('error');
5959
fail('Expected to throw');
6060
} catch (e) {
61-
expect(e.message).toBe(
61+
expect((e as Error).message).toBe(
6262
'Failed to find element matching one of the following queries:' +
6363
'\n(HarnessLoader for element matching selector: "error")',
6464
);
@@ -82,7 +82,7 @@ export function crossEnvironmentSpecs(
8282
await countersLoader.getHarness(SubComponentHarness);
8383
fail('Expected to throw');
8484
} catch (e) {
85-
expect(e.message).toBe(
85+
expect((e as Error).message).toBe(
8686
'Failed to find element matching one of the following queries:' +
8787
'\n(SubComponentHarness with host element matching selector: "test-sub")',
8888
);
@@ -112,7 +112,7 @@ export function crossEnvironmentSpecs(
112112
await harness.errorItem();
113113
fail('Expected to throw');
114114
} catch (e) {
115-
expect(e.message).toBe(
115+
expect((e as Error).message).toBe(
116116
'Failed to find element matching one of the following queries:' +
117117
'\n(TestElement for element matching selector: "wrong locator")',
118118
);
@@ -147,7 +147,7 @@ export function crossEnvironmentSpecs(
147147
await harness.errorSubComponent();
148148
fail('Expected to throw');
149149
} catch (e) {
150-
expect(e.message).toBe(
150+
expect((e as Error).message).toBe(
151151
'Failed to find element matching one of the following queries:' +
152152
'\n(WrongComponentHarness with host element matching selector: "wrong-selector")',
153153
);
@@ -211,7 +211,7 @@ export function crossEnvironmentSpecs(
211211
await harness.requiredAncestorRestrictedMissingSubcomponent();
212212
fail('Expected to throw');
213213
} catch (e) {
214-
expect(e.message).toBe(
214+
expect((e as Error).message).toBe(
215215
'Failed to find element matching one of the following queries:' +
216216
'\n(SubComponentHarness with host element matching selector: "test-sub"' +
217217
' satisfying the constraints: has ancestor matching selector ".not-found")',
@@ -311,7 +311,7 @@ export function crossEnvironmentSpecs(
311311
await harness.requiredFourIteamToolsLists();
312312
fail('Expected to throw');
313313
} catch (e) {
314-
expect(e.message).toBe(
314+
expect((e as Error).message).toBe(
315315
'Failed to find element matching one of the following queries:' +
316316
'\n(SubComponentHarness with host element matching selector: "test-sub" satisfying' +
317317
' the constraints: title = "List of test tools", item count = 4)',
@@ -640,7 +640,7 @@ export function crossEnvironmentSpecs(
640640
await harness.missingElementsAndHarnesses();
641641
fail('Expected to throw.');
642642
} catch (e) {
643-
expect(e.message).toBe(
643+
expect((e as Error).message).toBe(
644644
'Failed to find element matching one of the following queries:' +
645645
'\n(TestElement for element matching selector: ".not-found"),' +
646646
'\n(SubComponentHarness with host element matching selector: "test-sub" satisfying' +

src/material/schematics/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"outDir": "../../../dist/packages/material/schematics",
77
"noEmitOnError": false,
88
"strictNullChecks": true,
9+
"useUnknownInCatchVariables": true,
910
"noImplicitOverride": true,
1011
"noImplicitAny": true,
1112
"noFallthroughCasesInSwitch": true,

tools/dgeni/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"moduleResolution": "node",
77
"esModuleInterop": true,
88
"strictNullChecks": true,
9+
"useUnknownInCatchVariables": true,
910
"noImplicitReturns": true,
1011
"strictFunctionTypes": true,
1112
"noImplicitThis": true,

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"noFallthroughCasesInSwitch": true,
1212
"noUnusedLocals": false,
1313
"strictNullChecks": true,
14+
"useUnknownInCatchVariables": true,
1415
"noImplicitOverride": true,
1516
"noImplicitReturns": true,
1617
"strictFunctionTypes": true,

0 commit comments

Comments
 (0)