diff --git a/docs/tsconfig/zh/intro.md b/docs/tsconfig/zh/intro.md index f21815a6..49d8b6cb 100644 --- a/docs/tsconfig/zh/intro.md +++ b/docs/tsconfig/zh/intro.md @@ -1,6 +1,18 @@ -## TSConfig 前言 +--- +header: TSConfig 介绍 +firstLine: TSConfig 文件象征着,它所在的目录是一个 TypeScript 项目或者 JavaScript 项目的根目录... +--- -目录中的 TSConfig 文件表明该目录是 TypeScript 或 JavaScript 项目的根目录。 -TSConfig 文件可以是 `tsconfig.json` 或 `jsconfig.json`,它们的配置项和行为相同。 -此页涵盖了 TSConfig 文件中可用的所有不同选项。本页从每个选项的概述开始,到 JSON 文件的根属性,然后是`compilerOptions`(大部分选项),最后是 `watchOptions`。 +TSConfig 文件象征着,它所在的目录是一个 TypeScript 项目或者 JavaScript 项目的根目录。 +TSConfig 文件可以是 `tsconfig.json` 或 `jsconfig.json`,它们的配置相同。 + +此页涵盖了 TSConfig 文件中可用的所有不同选项。同时没有按照线性叙述来构建,而是分为了5个主要部分: + +- 一个配置项的分类概览 +- [root fields](#Project_Files_0): 告知 TypeScript 哪些文件需要被处理 +- [`compilerOptions`](#compilerOptions): 本页的主要内容 +- [`watchOptions`](#watchOptions): 配置监听模式 +- [`typeAcquisition`](#typeAcquisition): 配置 JavaScript 项目使用类型的方式 + +如果你是从零开始 TSConfig,可以考虑使用 `tsc --init` 或者 [TSConfig base](https://github.com/tsconfig/bases#centralized-recommendations-for-tsconfig-bases) 来进行配置。 \ No newline at end of file diff --git a/docs/tsconfig/zh/options/exclude.md b/docs/tsconfig/zh/options/exclude.md new file mode 100644 index 00000000..9b1ae968 --- /dev/null +++ b/docs/tsconfig/zh/options/exclude.md @@ -0,0 +1,11 @@ +--- +display: "Exclude" +oneline: "过滤 [`include`](#include) 选项。" +--- + +在解析 [`include`](#include) 选项时,需要跳过的文件名称或文件匹配器的列表。 + +**Important**: `exclude` _仅仅_ 改变 [`include`](#include) 选项包含的文件。 +`exclude` 指定的文件可能仍然是你代码的一部分,由于 被 `import` 引入到你的代码中,或者被 `types` 包含,或者使用 `/// + +``` +. +├── scripts ⨯ +│ ├── lint.ts ⨯ +│ ├── update_deps.ts ⨯ +│ └── utils.ts ⨯ +├── src ✓ +│ ├── client ✓ +│ │ ├── index.ts ✓ +│ │ └── utils.ts ✓ +│ ├── server ✓ +│ │ └── index.ts ✓ +├── tests ✓ +│ ├── app.test.ts ✓ +│ ├── utils.ts ✓ +│ └── tests.d.ts ✓ +├── package.json +├── tsconfig.json +└── yarn.lock +``` + +`include` 和 `exclude` 匹配器支持的匹配符: + +- `*` 匹配零个或多个字符 (不包含目录分割符) +- `?` 匹配任何一个字符 (不包含目录分割符) +- `**/` 匹配任何深度的目录 + +如果匹配器不包含文件拓展名只,支持特定拓展名的文件。默认支持 `.ts`, `.tsx`和 `.d.ts`,如果开启了 [`allowJs`](#allowJs),额外支持 `.js` 和 `.jsx`。