fix(weapp/updateShareMenu): 修正 updateShareMenu 的类型定义 - #18603
Conversation
Walkthrough更新 Taro 分享菜单类型定义:在 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 分钟
Suggested reviewers
诗
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro/types/api/share/index.d.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/taro/types/api/share/index.d.ts (1)
packages/taro-runtime-rn/src/types/index.d.ts (1)
CallbackResult(176-178)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
🔇 Additional comments (5)
packages/taro/types/api/share/index.d.ts (5)
6-13: 字段定义正确,文档完善。
withShareTicket和isUpdatableMessage字段的类型定义和文档注释都很规范,正确包含了默认值和相关文档链接。
20-37: 新增字段定义规范。
templateInfo、isPrivateMessage、participant、useForChatTool和chooseType字段的类型定义正确,文档注释清晰,包含了适当的默认值说明。
40-43: 回调函数定义符合标准。
fail和complete回调函数的类型定义与文件中其他 API 保持一致,符合 Taro 的标准回调模式。
50-51: 模板 ID 字段定义正确。
templateId字段被正确定义为必填的字符串类型,符合模板信息的设计要求。
5-44: 验证完成:所有新增字段均符合官方文档。经过官方微信开放文档验证,代码中新增的所有字段均已确认:
- 基础字段 withShareTicket、isUpdatableMessage、activityId 和 toDoActivityId 都在官方文档中得到支持,其中 toDoActivityId 用于聚合群待办消息
- templateInfo 用于动态消息的模板信息
- isPrivateMessage 用于转发私密消息
- 聊天工具相关字段 useForChatTool、chooseType 和 participant 也都在官方文档中定义,其中 useForChatTool 为 true 时才会启用 chooseType 和 participant,chooseType = 1 表示按指定 participant 作为参与者,chooseType = 2 表示群内所有成员均为参与者
- success、fail、complete 回调均为标准参数
类型定义完整准确,无需修改。
| /** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId)) 接口获取 | ||
| */ | ||
| activityId?: string |
There was a problem hiding this comment.
修复 JSDoc 注释中的链接错误。
第 14 行的注释中链接包含 errorupdatableMessage,应该改为 updatableMessage。
应用此修改来修复链接:
- /** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId)) 接口获取
+ /** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/updatableMessage.createActivityId) 接口获取
*/📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId)) 接口获取 | |
| */ | |
| activityId?: string | |
| /** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/updatableMessage.createActivityId) 接口获取 | |
| */ | |
| activityId?: string |
🤖 Prompt for AI Agents
packages/taro/types/api/share/index.d.ts 行 14-16: JSDoc 注释中的链接把
`updatableMessage` 错误地写成了 `errorupdatableMessage`,请将注释中的 URL 路径部分修正为包含
`updatableMessage.createActivityId`(即把 `errorupdatableMessage` 改为
`updatableMessage`),确保最终注释中的链接指向正确的接口文档并保持原有描述不变。
| /** 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html | ||
| */ | ||
| toDoActivityId?: string |
There was a problem hiding this comment.
修复 JSDoc 注释中的多处错误。
第 17 行的注释存在两个问题:
- 链接中包含
errorupdatableMessage,应为updatableMessage - 链接末尾缺少闭合括号
应用此修改来修复问题:
- /** 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html
+ /** 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/updatableMessage.createActivityId) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html)
*/📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html | |
| */ | |
| toDoActivityId?: string | |
| /** 群待办消息的id,通过toDoActivityId可以把多个群待办消息聚合为同一个。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/updatableMessage.createActivityId) 接口获取。详见[群待办消息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) | |
| */ | |
| toDoActivityId?: string |
🤖 Prompt for AI Agents
In packages/taro/types/api/share/index.d.ts around lines 17 to 19, the JSDoc for
toDoActivityId contains two mistakes: the embedded link wrongly includes
"errorupdatableMessage" instead of "updatableMessage" and the closing
parenthesis for the link is missing; update the link to use
".../updatableMessage.createActivityId" and add the missing closing parenthesis
so the URL and parentheses are correct in the JSDoc comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18603 +/- ##
========================================
Coverage 56.33% 56.33%
========================================
Files 447 447
Lines 23342 23342
Branches 5793 5759 -34
========================================
Hits 13149 13149
+ Misses 8493 8360 -133
- Partials 1700 1833 +133
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/taro/types/api/share/index.d.ts (1)
14-19: 修复 JSDoc 注释中的链接错误。这两个字段的 JSDoc 注释中存在之前已经指出的问题:
- 第 14 行:链接中的
errorupdatableMessage应为updatableMessage,且末尾多了一个闭合括号))应改为)- 第 17 行:链接中的
errorupdatableMessage应为updatableMessage,且第二个链接末尾缺少闭合括号)参考之前的审查意见进行修复。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro/types/api/share/index.d.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/taro/types/api/share/index.d.ts (1)
packages/taro-runtime-rn/src/types/index.d.ts (1)
CallbackResult(176-178)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (2)
packages/taro/types/api/share/index.d.ts (2)
6-13: 新增字段定义正确。
withShareTicket和isUpdatableMessage字段的类型定义、默认值和文档说明都很清晰,与微信小程序 API 保持一致。
20-43: 接口扩展完整,类型定义准确。新增的字段(
templateInfo、isPrivateMessage、participant、useForChatTool、chooseType)以及回调函数(fail、complete)的类型定义都很规范:
- 所有字段都正确标记为可选
- 提供了清晰的 JSDoc 文档说明
- 默认值使用
@default标签明确标注- 回调函数的顺序(success、fail、complete)与文件中其他接口保持一致
| /** 模板ID */ | ||
| templateId: string |
There was a problem hiding this comment.
🧩 Analysis chain
请验证 templateId 是否应为必需字段。
templateId 被定义为必需字段(没有 ? 标记),请确认这与微信小程序官方文档一致。如果在某些场景下 templateInfo 对象可以不包含 templateId,则应将其标记为可选字段。
🌐 Web query:
微信小程序 updateShareMenu 接口中 templateInfo 的 templateId 字段是必需的还是可选的?
💡 Result:
templateId 不是必需的。wx.updateShareMenu 的 templateInfo 本身为可选字段;只在声明为动态消息(isUpdatableMessage: true)或私密消息等场景时传入 templateInfo(其中需要提供 parameterList 等内容)。参考文档说明 templateInfo 为“否/可选”。[1][2]
参考:
[1] Taro 文档 — updateShareMenu(templateInfo 标注为“否/可选”)。
[2] 小程序 wx.updateShareMenu 参数说明(templateInfo 为可选,parameterList 在存在时为必填)。
templateId 应标记为可选字段。
根据微信小程序官方文档,templateInfo 本身为可选字段,templateId 不是必需的。请在 templateId 后添加 ? 标记以表示为可选字段:
/** 模板ID */
- templateId: string
+ templateId?: string📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /** 模板ID */ | |
| templateId: string | |
| /** 模板ID */ | |
| templateId?: string |
🤖 Prompt for AI Agents
In packages/taro/types/api/share/index.d.ts around lines 50-51, the templateId
property is currently required but should be optional per WeChat Mini Program
docs; update the declaration by adding a question mark to templateId
(templateId?: string) so the type reflects that templateInfo/templateId may be
omitted.
这个 PR 做了什么? (简要描述所做更改)
修正 updateShareMenu 的类型定义
ref: https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.updateShareMenu.html
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit