Skip to content

fix(weapp/updateShareMenu): 修正 updateShareMenu 的类型定义 - #18603

Merged
Single-Dancer merged 1 commit into
NervJS:mainfrom
Runc2333:main
Nov 12, 2025
Merged

Single-Dancer merged 1 commit into
NervJS:mainfrom
Runc2333:main

Conversation

@Runc2333

@Runc2333 Runc2333 commented Nov 9, 2025 •

Copy link
Copy Markdown
Contributor

这个 PR 做了什么? (简要描述所做更改)

修正 updateShareMenu 的类型定义
ref: https://developers.weixin.qq.com/miniprogram/dev/api/share/wx.updateShareMenu.html

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 新功能
    • 扩展分享菜单配置:新增分享凭证、可更新消息、待办活动ID、模板信息(含模板ID)等多项开关与元数据。
    • 支持私密消息、参与者列表管理、用于聊天工具的配置与选择类型。
    • 完善分享操作的回调处理(成功/失败/完成)。

@coderabbitai

coderabbitai Bot commented Nov 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

更新 Taro 分享菜单类型定义:在 updateShareMenu.Option 中新增并重新排序多个可选字段,并添加 UpdatableMessageFrontEndTemplateInfo 的必需属性 templateId。

Changes

Cohort / File(s) 变更总结
分享菜单类型变更
packages/taro/types/api/share/index.d.ts
在 updateShareMenu.Option 接口中新增/重排字段:新增 withShareTicket?: boolean、isUpdatableMessage?: boolean、(重新定位)activityId?: string、toDoActivityId?: string、templateInfo?: UpdatableMessageFrontEndTemplateInfo、isPrivateMessage?: boolean、participant?: string[]、useForChatTool?: boolean、chooseType?: number,并添加回调 fail?: (res: TaroGeneral.CallbackResult) => void、complete?: (res: TaroGeneral.CallbackResult) => void;新增接口 UpdatableMessageFrontEndTemplateInfo,包含必需字段 templateId: string。变更主要为类型声明调整与扩展,顺序有所调整。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 分钟

  • 仅修改单个 TypeScript 类型声明文件,变更为新增/重排可选字段,逻辑密度低且模式一致。
  • 建议重点检查:
    • 新增字段名称、类型与官方/目标平台文档一致性(如 WeChat API)。
    • templateInfo 类型定义与其使用方的一致性。
    • 字段顺序变更是否影响导出类型的可读性或自动生成文档。

Suggested reviewers

  • Single-Dancer
  • yoyo837

诗

🐰 字段跳进类型池,轻盈一跃不费力,
分享菜单加新意,模板 ID 闪着光,
可选项排好队,TypeScript 心里喜。

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰准确地描述了主要变更:修正 updateShareMenu 的类型定义,直接对应 TypeScript 类型定义文件的更新。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a018f9d and a916ffa.

📒 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 回调均为标准参数

类型定义完整准确,无需修改。

Comment on lines +14 to +16
/** 动态消息的 activityId。通过 [updatableMessage.createActivityId](https://developers.weixin.qq.com/miniprogram/dev/api/share/errorupdatableMessage.createActivityId)) 接口获取
*/
activityId?: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

修复 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.

Suggested change
/** 动态消息的 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`),确保最终注释中的链接指向正确的接口文档并保持原有描述不变。

Comment on lines +17 to +19
/** 群待办消息的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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

修复 JSDoc 注释中的多处错误。

第 17 行的注释存在两个问题:

  1. 链接中包含 errorupdatableMessage,应为 updatableMessage
  2. 链接末尾缺少闭合括号

应用此修改来修复问题:

-      /** 群待办消息的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.

Suggested change
/** 群待办消息的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

codecov Bot commented Nov 9, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.33%. Comparing base (2de8374) to head (9371323).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 60.33% <ø> (ø)
taro-web 53.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 44 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a916ffa and 9371323.

📒 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)与文件中其他接口保持一致

Comment on lines +50 to +51
/** 模板ID */
templateId: string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 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.

Suggested change
/** 模板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.

@Single-Dancer
Single-Dancer merged commit ee3f700 into NervJS:main Nov 12, 2025
24 checks passed
@Single-Dancer Single-Dancer added this to the 4.1.9 milestone Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants