Skip to content

Commit 2ed02f1

Browse files
committed
Add useUnknownInCatchVariables -> recommended
1 parent f189f5b commit 2ed02f1

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

packages/tsconfig-reference/scripts/tsconfigRules.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import remark from "remark";
33
import remarkHTML from "remark-html";
44
import ts from "typescript";
55

6+
declare module "typescript" {
7+
const optionDeclarations: CommandLineOption[];
8+
const optionsForWatch: CommandLineOption[];
9+
const typeAcquisitionDeclarations: CommandLineOption[];
10+
const defaultInitCompilerOptions: ts.CompilerOptions;
11+
}
12+
613
export interface CommandLineOption {
714
name: string;
815
type:
@@ -14,15 +21,10 @@ export interface CommandLineOption {
1421
| Map<string, number | string>;
1522
defaultValueDescription?: string | number | boolean | ts.DiagnosticMessage;
1623
category?: ts.DiagnosticMessage;
24+
strictFlag?: true;
1725
element: CommandLineOption;
1826
}
1927

20-
declare module "typescript" {
21-
const optionDeclarations: CommandLineOption[];
22-
const optionsForWatch: CommandLineOption[];
23-
const typeAcquisitionDeclarations: CommandLineOption[];
24-
}
25-
2628
/**
2729
* Changes to these rules should be reflected in the following files:
2830
* https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json
@@ -72,18 +74,17 @@ export const buildOptionCompilerOptNames: string[] = ts.buildOpts
7274
export const rootOptNames = ["files", "extends", "include", "exclude", "references"];
7375

7476
/** You should use this! They are off by default */
75-
export const recommended: CompilerOptionName[] = [
76-
"strict",
77-
"forceConsistentCasingInFileNames",
78-
"alwaysStrict",
79-
"strictNullChecks",
80-
"strictBindCallApply",
81-
"strictFunctionTypes",
82-
"strictPropertyInitialization",
83-
"noImplicitThis",
84-
"noImplicitAny",
85-
"esModuleInterop",
86-
"skipLibCheck",
77+
export const recommended = [
78+
// Options enabled by --init
79+
...Object.entries(ts.defaultInitCompilerOptions)
80+
.filter(([, value]) => value === true)
81+
.map(([name]) => name),
82+
// Options enabled by --strict
83+
...ts.optionDeclarations
84+
.filter((option) => option.strictFlag)
85+
.map((option) => option.name),
86+
// Not included in --init yet:
87+
// https://github.com/microsoft/TypeScript/issues/44524#:~:text=--init%20should%20include%20it%20once%20the%20ecosystem%20catches%20up.
8788
"exactOptionalPropertyTypes",
8889
];
8990

0 commit comments

Comments
 (0)