Skip to content
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

docs: 更新 TypeScript 类型配置说明,添加三斜线指令配置示例 #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vanisper
Copy link
Contributor

@Vanisper Vanisper commented Mar 14, 2025

Description 描述

文档更新:

  1. 部分不对应的文案修改。
  2. 添加 TypeScript 类型配置说明,添加三斜线指令配置示例,以达到最简配置的效果。

Linked Issues 关联的 Issues

暂无

Additional context 额外上下文

  1. 关于文案修改部分

// 为 uni-app 组件提供 TypeScript 类型,需要安装 @uni-helper/uni-cloud-types

以上的注释存在于 uni-cloud-types.md 中,此处讲述的应该是 uni-cloud 组件 而不是 uni-app 组件

相关的还有

// 为 uni-app 组件提供 TypeScript 类型,需要安装 @uni-helper/uni-types

  1. 关于 三斜线指令 配置取代 compilerOptions.types 配置

此配置是为了尽可能实现最简配置,理由是

ts 项目大多会在 tsconfig.jsoninclude 字段中包含 src/**/*.d.ts,所以在 src 目录下新建任意的 *.d.ts 文件;

然后在其头部中添加 /// <reference types="..." /> 就能命中 types 的配置,尽可能实现最简配置。

经测试,此种配置能使编辑器 即时 对类型的提示做出响应,无需重启编辑器(可能存在个体性差异)。

当然,此处的配置说明仅仅是作为 增量说明 存在的,并未对原有配置的说明有侵入。

Summary by CodeRabbit

  • Documentation
    • Added comprehensive guides detailing how to configure TypeScript using triple-slash directives.
    • Introduced step-by-step instructions for setting up a global type definitions file and updating your project’s configuration.
    • Enhanced explanatory tips for managing types across multiple documentation sections, streamlining the setup process for a smoother development experience.

Copy link

coderabbitai bot commented Mar 14, 2025

Walkthrough

This pull request updates several documentation files by adding detailed sections on configuring TypeScript with triple-slash directives. The new instructions guide users through creating a global type definition file (src/global.d.ts), adding reference directives for various APIs, and updating the tsconfig.json file to include the definitions. In addition, package comments for @uni-helper/uni-cloud-types and @uni-helper/uni-types are updated for clearer descriptions. No changes were made to any exported or public entities.

Changes

File(s) Change Summary
docs/guide/uni-app-types.md, docs/guide/uni-ui-types.md Added new sections detailing how to create a global type definition file with triple-slash directives, and how to update the tsconfig.json to include it.
docs/guide/uni-cloud-types.md, docs/guide/uni-types.md Updated package comments (uni-cloud-types now for "uni-cloud components" and uni-types for multiple component sets) and added guidance on triple-slash configuration.

Sequence Diagram(s)

sequenceDiagram
    participant D as Developer
    participant Doc as Documentation
    participant G as global.d.ts File
    participant T as tsconfig.json
    participant TS as TypeScript Compiler

    D->>Doc: Read configuration guide
    D->>G: Create global.d.ts with guidance content
    D->>T: Update tsconfig.json to include global.d.ts
    TS-->>G: Load global type declarations
    TS-->>D: Provide enhanced type checking support
Loading

Poem

Oh, I hopped through docs today,
With triple-slash steps leading the way,
A global file now in my sight,
And tsconfig set up just right,
My rabbit cheers for guidelines so bright! 🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 818e4ee and a1123e7.

📒 Files selected for processing (4)
  • docs/guide/uni-app-types.md (1 hunks)
  • docs/guide/uni-cloud-types.md (1 hunks)
  • docs/guide/uni-types.md (2 hunks)
  • docs/guide/uni-ui-types.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test (windows-latest, 22)
  • GitHub Check: test (windows-latest, 18)
🔇 Additional comments (6)
docs/guide/uni-cloud-types.md (2)

90-91: Clarify the TypeScript types entry for uni-cloud components.
The change updates the comment and the entry within the types array to clearly indicate that it provides TypeScript types for uni‑cloud components (and not uni‑app components). This improves clarity in the configuration instructions.


98-134: Comprehensive Triple‑Slash Directives Instructions Added.
The newly added tip section explains in detail how to use triple‑slash directives as an alternative to the compilerOptions.types configuration. It provides clear, step‑by‑step instructions for creating a global type definition file (src/global.d.ts) and updating tsconfig.json accordingly. This is a very helpful enhancement for users seeking a minimal and streamlined configuration.

docs/guide/uni-ui-types.md (1)

105-143: Detailed Triple‑Slash Directives Configuration for uni‑ui Types.
The added section thoroughly explains how to leverage triple‑slash directives to configure TypeScript for uni‑ui components. It walks the user through creating a global type definition file and updating their tsconfig.json, which should simplify setup and reduce confusion regarding the inclusion of types.

docs/guide/uni-types.md (2)

91-92: Update TypeScript types entry for uni‑types.
The modified comment and entry now correctly state that the package provides TypeScript types for uni‑app, uni‑cloud, and uni‑ui components. This update aligns the documentation with the package’s scope and usage.


103-139: Addition of Triple‑Slash Directives Instructions.
This new tip section offers a clear, step‑by‑step guide on using triple‑slash directives to achieve TypeScript configuration. The instructions for creating a src/global.d.ts file and updating the tsconfig.json are well documented and offer a simplified configuration alternative.

docs/guide/uni-app-types.md (1)

103-139: Incorporation of Triple‑Slash Directives for uni‑app Types.
The newly introduced section clearly describes how to use triple‑slash directives to configure TypeScript for uni‑app components. The step‑by‑step explanation—including the creation of the src/global.d.ts file and the modification of tsconfig.json—enhances the documentation and should aid developers in setting up their projects more effortlessly.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Mar 14, 2025

Deploy Preview for uni-typed ready!

Name Link
🔨 Latest commit a1123e7
🔍 Latest deploy log https://app.netlify.com/sites/uni-typed/deploys/67d42971e22ff80008f2c184
😎 Deploy Preview https://deploy-preview-31--uni-typed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

pkg-pr-new bot commented Mar 14, 2025

Open in Stackblitz

@uni-helper/uni-app-components

npm i https://pkg.pr.new/@uni-helper/uni-app-components@31

@uni-helper/uni-app-types

npm i https://pkg.pr.new/@uni-helper/uni-app-types@31

@uni-helper/uni-cloud-types

npm i https://pkg.pr.new/@uni-helper/uni-cloud-types@31

@uni-helper/uni-types

npm i https://pkg.pr.new/@uni-helper/uni-types@31

@uni-helper/uni-ui-types

npm i https://pkg.pr.new/@uni-helper/uni-ui-types@31

commit: a1123e7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant