feat: add .d.ts for @tarojs/extend (based on @types/zepto)
这个 PR 做了什么? (简要描述所做更改) 修复@tarojs/extend缺乏类型声明
这个 PR 是什么类型? (至少选择一个)
- [*] 错误修复 (Bugfix) issue: fix #17795
- [*] 新功能 (Feature)
- [ ] 代码重构 (Refactor)
- [*] TypeScript 类型定义修改 (Types)
- [ ] 文档修改 (Docs)
- [ ] 代码风格更新 (Code style update)
- [ ] 构建优化 (Chore)
- [ ] 其他,请描述 (Other, please describe):
这个 PR 涉及以下平台:
- [*] 所有小程序
- [ ] 微信小程序
- [ ] 支付宝小程序
- [ ] 百度小程序
- [ ] 字节跳动小程序
- [ ] QQ 轻应用
- [ ] 京东小程序
- [ ] 快应用平台(QuickApp)
- [ ] Web 平台(H5)
- [ ] 移动端(React-Native)
- [ ] 鸿蒙(harmony)
Summary by CodeRabbit
- 新功能
- 为 Zepto 库引入了完整的 TypeScript 类型声明,提升了类型安全和智能提示体验。
- 现在在 TypeScript 项目中使用 Zepto 时可获得完善的接口和方法类型支持。
"""
Walkthrough
本次变更为 @tarojs/extend 包新增了完整的 TypeScript 声明文件,并在 package.json 中配置了 types 字段及相关文件目录,以确保类型声明能被正确分发和识别。未涉及其他功能或代码的修改。
Changes
| 文件/文件组 | 变更摘要 |
|---|---|
| packages/taro-extend/package.json | 增加 "types" 字段指向 "types/index.d.ts",并将 "types" 目录加入 "files" 数组 |
| packages/taro-extend/types/index.d.ts | 新增 Zepto 相关完整 TypeScript 类型声明文件 |
Sequence Diagram(s)
sequenceDiagram
participant TSUser as TypeScript 用户
participant TaroExtend as @tarojs/extend
participant Types as types/index.d.ts
TSUser->>TaroExtend: import '@tarojs/extend'
TaroExtend-->>Types: 查找 types/index.d.ts
Types-->>TSUser: 提供 Zepto API 类型声明
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| 为 @tarojs/extend 包提供 TypeScript 声明文件,解决“Could not find a declaration file for module @tarojs/extend”报错 (#17795) | ✅ |
Assessment against linked issues: Out-of-scope changes
(未发现超出已关联 issue 目标范围的代码变更)
Poem
兔子敲键,类型声明添,
Zepto API,类型齐全。
TS 再无错,导入不再烦,
代码如春风,开发乐无边。
(づ。◕‿‿◕。)づ """
📜 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 c4f704c25afafa553a1e4a237507063422b24f45 and b0c7c73af0ce4704b0cd5756e431ceebdf24c31e.
📒 Files selected for processing (2)
packages/taro-extend/package.json(1 hunks)packages/taro-extend/types/index.d.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/taro-extend/package.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/taro-extend/types/index.d.ts
[error] 208-208: Don't use 'Function' as a type.
Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.
(lint/complexity/noBannedTypes)
[error] 210-211: Don't use 'Function' as a type.
Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.
(lint/complexity/noBannedTypes)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (2)
packages/taro-extend/types/index.d.ts (2)
27-1661: 类型声明文件实现完整且结构良好该声明文件提供了全面的 Zepto 库类型定义,包括:
- 核心 ZeptoStatic 接口覆盖所有静态方法
- ZeptoCollection 接口包含完整的链式操作方法
- Ajax 相关接口支持各种请求配置
- 动画和效果相关类型定义
- 事件处理器的正确类型声明
方法重载和可选参数的使用恰当,为 TypeScript 用户提供了良好的类型安全和智能提示支持。
1662-1665: 全局声明和导出配置正确正确声明了全局变量
Zepto和$,并通过命名导出支持模块化使用,兼容浏览器全局使用和 ES6/CommonJS 模块导入两种场景。
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Post Copyable Unit Tests in Comment
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.
🪧 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.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 explain its main purpose.@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.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 55.90%. Comparing base (
5684874) to head (b0c7c73). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #17796 +/- ##
========================================
Coverage 55.90% 55.90%
========================================
Files 417 417
Lines 21693 21693
Branches 5355 5365 +10
========================================
Hits 12127 12127
- Misses 7970 8087 +117
+ Partials 1596 1479 -117
| Flag | Coverage Δ | |
|---|---|---|
| taro-cli | 72.42% <ø> (ø) |
|
| taro-runtime | 59.87% <ø> (ø) |
|
| taro-web | 53.19% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.