Skip to content

Commit

Permalink
feat(lsp): turn on useUnknownInCatchVariables (#25474)
Browse files Browse the repository at this point in the history
  • Loading branch information
petamoriken authored Sep 6, 2024
1 parent 56363e4 commit 8ef08f1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@ impl Default for LspTsConfig {
"strict": true,
"target": "esnext",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": false,
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
Expand Down
2 changes: 1 addition & 1 deletion cli/schemas/config-file.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"useUnknownInCatchVariables": {
"description": "Default catch clause variables as `unknown` instead of `any`.",
"type": "boolean",
"default": false,
"default": true,
"markdownDescription": "Default catch clause variables as `unknown` instead of `any`.\n\nSee more: https://www.typescriptlang.org/tsconfig#useUnknownInCatchVariables"
}
}
Expand Down
1 change: 0 additions & 1 deletion cli/tsc/99_main_compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,6 @@ delete Object.prototype.__proto__;
"strict": true,
"target": "esnext",
"useDefineForClassFields": true,
"useUnknownInCatchVariables": false,
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"args": "check main.ts",
"output": "main.out",
"exitCode": 1
}
5 changes: 5 additions & 0 deletions tests/specs/check/use_unknown_in_catch_variables/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Check file:///[WILDCARD]/main.ts
error: TS18046 [ERROR]: 'e' is of type 'unknown'.
console.log(e.message);
^
at file://[WILDCARD]/use_unknown_in_catch_variables/main.ts:4:15
5 changes: 5 additions & 0 deletions tests/specs/check/use_unknown_in_catch_variables/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
try {
throw new Error();
} catch (e) {
console.log(e.message);
}

0 comments on commit 8ef08f1

Please sign in to comment.