-
-
Notifications
You must be signed in to change notification settings - Fork 58
docs(zh): translate other zh docs #551
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
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
c22dcbd
docs: quick-start
SoonIter e7de324
docs: glossary
SoonIter 45fb04c
docs: packages
SoonIter 9e5dd24
docs: solution
SoonIter b244a96
docs: mf dts
SoonIter 972876d
chore: update
SoonIter c667148
chore: update
SoonIter c5e0064
chore: aligned with Rsbuild
SoonIter c2463a4
chore: fix
SoonIter eb2b769
chore: fix
SoonIter 6aea6ea
chore: fix
SoonIter e902ea2
chore: suggestion fix
SoonIter afbceda
chore: remove banner
SoonIter 04c8625
chore: polish bundless
SoonIter 77bad44
chore: devDepdencies
SoonIter 6edf7d3
chore: rslib mf dev
SoonIter c0679de
chore: rslib mf dev
SoonIter 8e837fb
chore: HMR
SoonIter 198b471
chore: 编写
SoonIter cd0f20c
chore: Period
SoonIter 86cf46e
Update website/docs/zh/guide/advanced/module-federation.mdx
SoonIter a90d78d
Update website/docs/zh/guide/advanced/module-federation.mdx
SoonIter cecc547
Apply suggestions from code review
SoonIter 9b811dc
Update website/docs/zh/guide/solution/react.mdx
SoonIter adab865
chore: fix
SoonIter 298d396
chore: fix
SoonIter 3e14b2f
chore: fix
SoonIter 61446a1
chore: fix
SoonIter f209a34
Merge branch 'main' into docs-green
Timeless0911 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,65 @@ | ||
| # 类型生成 | ||
|
|
||
| 本章介绍什么是 TypeScript 声明文件(DTS)以及如何在 Rslib 中生成 DTS 文件。 | ||
|
|
||
| ## 什么是 DTS | ||
|
|
||
| TypeScript 声明文件 (DTS) 提供 JavaScript 代码的类型信息。 DTS 文件通常具有 `.d.ts` 扩展名。它们允许 TypeScript 编译器理解 JavaScript 代码的类型结构,从而实现以下功能: | ||
|
|
||
| 1. **类型检查**: 为 JavaScript 代码提供类型信息,帮助开发人员在编译时捕获潜在的类型错误。 | ||
| 2. **代码补全**: 增强代码编辑器功能,例如自动完成和代码导航。 | ||
| 3. **文档生成**: 生成 JavaScript 代码文档,提供更好的开发体验。 | ||
| 4. **IDE 支持**: 改善 Visual Studio Code、WebStorm 等 IDE 中的开发人员体验. | ||
SoonIter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 5. **库消费**: 让其他使用者更容易使用和理解该库。 | ||
|
|
||
| ## 什么是 Bundle DTS 和 Bundleless DTS | ||
|
|
||
| ### Bundle DTS | ||
|
|
||
| Bundle DTS 涉及将多个 TypeScript 声明文件 bundle 到一个声明文件中。 | ||
|
|
||
| - **优势:** | ||
|
|
||
| - **简化管理**: 简化类型文件的管理和引用。 | ||
| - **容易分发**: 减少用户使用库时需要处理的文件数量。 | ||
|
|
||
| - **劣势:** | ||
| - **生成复杂**: 在大型项目中,生成和维护单个 bundle 文件可能会变得复杂. | ||
SoonIter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **调试困难**: 调试类型问题可能不像各个文件单独输出那样直观。 | ||
|
|
||
| ### Bundleless DTS | ||
|
|
||
| Bundleless DTS 涉及为库中的每个模块生成单独的声明文件,就像 `tsc` 一样。 | ||
|
|
||
| - **优势:** | ||
|
|
||
| - **模块化**: 每个模块都有自己的类型定义,使维护和调试更容易。 | ||
| - **灵活**: 适合大型项目,避免单个文件的复杂性。 | ||
|
|
||
| - **劣势:** | ||
| - **多文件**: 用户在使用该库时可能需要处理多个声明文件。 | ||
| - **管理复杂**: 可能需要额外的配置才能正确引用所有文件。 | ||
|
|
||
| ## 怎么在 Rslib 中生成 DTS | ||
SoonIter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Rslib 默认使用 [TypeScript Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API) 生成 Bundleless DTS, [API Extractor](https://api-extractor.com/) | ||
|
|
||
| 如果你想生成 Bundleless DTS,可以: | ||
|
|
||
| - 设置 `dts: true` 或者 `dts: { bundle: false }` 在 Rslib 配置文件。 | ||
|
|
||
| 如果你想生成 Bundle DTS,可以: | ||
|
|
||
| 1. 安装 `@microsoft/api-extractor` 作为 `dev`, 这是用于 bundle DTS 文件的底层工具。 | ||
SoonIter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import { PackageManagerTabs } from '@theme'; | ||
|
|
||
| <PackageManagerTabs command="add @microsoft/api-extractor -D" /> | ||
|
|
||
| 2. 设置 `dts: { bundle: true }` 在 Rslib 配置文件中。 | ||
SoonIter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ::: tip | ||
|
|
||
| 你可以参考 [lib.dts](/config/lib/dts) 获取更多有关 DTS 配置的详细信息。 | ||
|
|
||
| ::: | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.