Skip to content

Add useUnknownInCatchVariables -> recommended #2251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions packages/tsconfig-reference/scripts/tsconfigRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import remark from "remark";
import remarkHTML from "remark-html";
import ts from "typescript";

declare module "typescript" {
const optionDeclarations: CommandLineOption[];
const optionsForWatch: CommandLineOption[];
const typeAcquisitionDeclarations: CommandLineOption[];
const defaultInitCompilerOptions: ts.CompilerOptions;
}

export interface CommandLineOption {
name: string;
type:
Expand All @@ -14,15 +21,10 @@ export interface CommandLineOption {
| Map<string, number | string>;
defaultValueDescription?: string | number | boolean | ts.DiagnosticMessage;
category?: ts.DiagnosticMessage;
strictFlag?: true;
element: CommandLineOption;
}

declare module "typescript" {
const optionDeclarations: CommandLineOption[];
const optionsForWatch: CommandLineOption[];
const typeAcquisitionDeclarations: CommandLineOption[];
}

/**
* Changes to these rules should be reflected in the following files:
* https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/tsconfig.json
Expand Down Expand Up @@ -72,18 +74,17 @@ export const buildOptionCompilerOptNames: string[] = ts.buildOpts
export const rootOptNames = ["files", "extends", "include", "exclude", "references"];

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

Expand Down