Skip to content

48441 Adding default values to properties in reference. #2449

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

Closed
wants to merge 1 commit into from
Closed
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
115 changes: 94 additions & 21 deletions packages/tsconfig-reference/scripts/tsconfigRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import ts from "typescript";
export interface CommandLineOption {
name: string;
type:
| "string"
| "number"
| "boolean"
| "object"
| "list"
| Map<string, number | string>;
| "string"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the formatting changes everywhere?

| "number"
| "boolean"
| "object"
| "list"
| Map<string, number | string>;
defaultValueDescription?: string | number | boolean | ts.DiagnosticMessage;
category?: ts.DiagnosticMessage;
element: CommandLineOption;
Expand Down Expand Up @@ -200,53 +200,126 @@ export const defaultsForOptions = {
typeof option.defaultValueDescription === "object"
? option.defaultValueDescription.message
: formatDefaultValue(
option.defaultValueDescription,
option.type === "list" ? option.element.type : option.type
),
option.defaultValueDescription,
option.type === "list" ? option.element.type : option.type
),
])
),
allowJs: "`false`",
allowSyntheticDefaultImports: [
"`true` if [`module`](#module) is `system`, or [`esModuleInterop`](#esModuleInterop) and [`module`](#module) is not `es6`/`es2015` or `esnext`,",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super sure why all of these trailing comments have been removed; they do look correct on the reference page.

"`true` if [`module`](#module) is `system`, or [`esModuleInterop`](#esModuleInterop) and [`module`](#module) is not `es6`/`es2015` or `esnext`",
"`false` otherwise.",
],
allowUmdGlobalAccess: "`false`",
allowUnreachableCode: "`false`",
allowUnusedLabels: "`false`",
alwaysStrict: trueIf("strict"),
assumeChangesOnlyAffectDirectDependencies: "`false`",
baseUrl: "`./`",
checkJs: "`false`",
composite: "`false`",
declaration: trueIf("composite"),
declarationDir: "`./`",
declarationMap: "`false`",
disableReferencedProjectLoad: "`false`",
disableSizeLimit: "`false`",
disableSolutionSearching: "`false`",
disableSourceOfProjectReferenceRedirect: "`false`",
downlevelIteration: "`false`",
emitBOM: "`false`",
emitDeclarationOnly: "`false`",
emitDecoratorMetadata: "`false`",
esModuleInterop: "`false`",
exactOptionalPropertyTypes: "`false`",
exclude: [
"node_modules",
"bower_components",
"jspm_packages",
"[`outDir`](#outDir)",
],
include: ["`[]` if [`files`](#files) is specified,", "`**` otherwise."],
experimentalDecorators: "`false`",
explainFiles: "`false`",
extendedDiagnostics: "`false`",
forceConsistentCasingInFileNames: "`false`",
importHelpers: "`false`",
importsNotUsedAsValues: "`remove`",
include: ["`[]` if [`files`](#files) is specified", "`**` otherwise."],
incremental: trueIf("composite"),
inlineSourceMap: "`false`",
inlineSources: "`false`",
isolatedModules: "`false`",
jsx: "`preserve`",
jsxFactory: "React.createElement",
keyOfStringsOnly: "``false",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here.

lib: "`[]`",
listEmittedFiles: "`false`",
listFiles: "`false`",
locale: "Platform specific.",
maxNodeModuleJsDepth: "`0`",
module: [
"`CommonJS` if [`target`](#target) is `ES3` or `ES5`,",
"`ES6`/`ES2015` otherwise.",
],
moduleResolution: [
"`Classic` if [`module`](#module) is `AMD`, `UMD`, `System` or `ES6`/`ES2015`,",
"Matches if [`module`](#module) is `node12` or `nodenext`,",
"`Classic` if [`module`](#module) is `AMD`, `UMD`, `System` or `ES6`/`ES2015`",
"Matches if [`module`](#module) is `node12` or `nodenext`",
"`Node` otherwise.",
],
moduleSuffixes: "`[]`",
newLine: "Platform specific.",
noEmit: "`false`",
noEmitHelpers: "`false`",
noEmitOnError: "`false`",
noErrorTruncation: "`false`",
noFallthroughCasesInSwitch: "`false`",
noImplicitAny: trueIf("strict"),
noImplicitOverride: "`false`",
noImplicitReturns: "`false`",
noImplicitUseStrict: "`false`",
noImplicitThis: trueIf("strict"),
noLib: "`false`",
noPropertyAccessFromIndexSignature: "`false`",
noResolve: "`false`",
noStrictGenericChecks: "`false`",
noUncheckedIndexedAccess: "`false`",
noUnusedLocals: "`false`",
noUnusedParameters: "`false`",
outDir: "`./`",
outFile: "`./`",
paths: "`{}`",
preserveConstEnums: trueIf("isolatedModules"),
preserveSymlinks: "`false`",
preserveValueImports: "`false`",
preserveWatchOutput: "`false`",
reactNamespace: "React",
rootDir: "Computed from the list of input files.",
rootDirs: "Computed from the list of input files.",
removeComments: "`false`",
resolveJsonModule: "`false`",
rootDir: [
"If [`composite`](#composite) is `true` the directory that contains `tsconfig.json`",
"otherwise the longest common path of all non-declaration input files.",
],
rootDirs: "`[]`",
skipDefaultLibCheck: "`false`",
skipLibCheck: "`false`",
sourceMap: "`false`",
sourceRoot: "",
strict: "`false`",
strictBindCallApply: trueIf("strict"),
strictFunctionTypes: trueIf("strict"),
useUnknownInCatchVariables: trueIf("strict"),
strictPropertyInitialization: trueIf("strict"),
strictNullChecks: trueIf("strict"),
stripInternal: "`false`",
suppressExcessPropertyErrors: "`false`",
suppressImplicitAnyIndexErrors: "`false`",
target: "ES3",
traceResolution: "`false`",
typeRoots: "All visible `@types` packages are included in compilation.",
types: "All visible `@types` packages are included in compilation.",
useDefineForClassFields: [
"`true` if [`target`](#target) is `ES2022` or higher, including `ESNext`,",
"`true` if [`target`](#target) is `ES2022` or higher, including `ESNext`",
"`false` otherwise.",
],
useUnknownInCatchVariables: trueIf("strict"),
};

function formatDefaultValue(
Expand Down Expand Up @@ -366,8 +439,8 @@ Object.keys(releaseToConfigsMap).forEach((v) => {
export const parseMarkdown = (value: string | string[]) =>
Array.isArray(value)
? `<ul>${value
.map((element) => `<li>${parseMarkdown(element)}</li>`)
.join("")}</ul>`
.map((element) => `<li>${parseMarkdown(element)}</li>`)
.join("")}</ul>`
: remark()
.use(remarkHTML)
.processSync(value !== undefined ? String(value).replace(/^[-.0-9_a-z]+$/i, "`$&`") : undefined);
.use(remarkHTML)
.processSync(value !== undefined ? String(value).replace(/^[-.0-9_a-z]+$/i, "`$&`") : undefined);