Skip to content

Conversation

Coder-Jack04
Copy link
Contributor

@Coder-Jack04 Coder-Jack04 commented Aug 30, 2025

Dialog.open方法的第二个参数类型和dialog支持的属性不同,现修复

Summary by CodeRabbit

  • 重构
    • 调整内部类型注解以提升类型安全与可维护性;不影响现有功能、界面或性能。

Copy link

coderabbitai bot commented Aug 30, 2025

Walkthrough

在 src/packages/dialog/dialog.taro.tsx 中,仅对 defaultProps 添加了类型断言,将其标注为 TaroDialogProps。未改动运行时逻辑、导出或公开 API。

Changes

Cohort / File(s) Summary of Changes
类型标注调整
src/packages/dialog/dialog.taro.tsx
为 defaultProps 添加 as TaroDialogProps 类型断言;无运行时行为变化;无公开实体签名变更。

Estimated code review effort

🎯 1(琐碎) | ⏱️ ~2 分钟

Possibly related PRs

Suggested reviewers

  • oasis-cloud
  • irisSong

Poem

小兔挥笔点断言,
类型安家更周全。
不惊流程不改面,
只把边界更清闲。
耳畔风轻:TS笑,📝
代码蹦跳:“稳如先。”

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@github-actions github-actions bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels Aug 30, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/packages/dialog/dialog.taro.tsx (1)

107-116: 覆盖 TaroDialogProps.onConfirm 类型并更新 handleOk 参数

  • src/types/spec/dialog/taro.ts 中,重写 onConfirm 签名,支持 Taro 触摸事件和 Web 鼠标事件:
    export interface TaroDialogProps extends Omit<BaseDialog, 'onOverlayClick' | 'onClick'> {
      onConfirm?: (event: ITouchEvent | MouseEvent<HTMLButtonElement>) => PromiseLike<any> | void
      
    }
  • src/packages/dialog/dialog.taro.tsx 中,将 handleOk 参数改为 (e: ITouchEvent | MouseEvent<HTMLButtonElement>),以匹配上述类型。
🧹 Nitpick comments (2)
src/packages/dialog/dialog.taro.tsx (2)

22-47: 避免 as 断言导致的类型逃逸,建议使用显式类型或显式入参类型

当前用 as TaroDialogProps 会跳过对象字面量的类型校验,后续属性收敛/变更时更容易漏报。给出两种更稳妥的替代方案:

  • 方案A(推荐,既保留 typeof,又保留编译期校验):为变量显式声明类型,移除断言
-const defaultProps = {
+const defaultProps: TaroDialogProps = {
   ...defaultOverlayProps,
   ...defaultContentProps,
   ...
-} as TaroDialogProps
+}
  • 方案B(解耦 open 的类型与 defaultProps 形状):保持字面量推断并用 satisfies 做校验,同时显式标注 open 入参类型
-const defaultProps = {
+const defaultProps = {
   ...defaultOverlayProps,
   ...defaultContentProps,
   ...
-} as TaroDialogProps
+} satisfies TaroDialogProps
@@
-export function open(selector: string, options: Partial<typeof defaultProps>) {
+export function open(selector: string, options: Partial<TaroDialogProps>) {

198-201: 命名笔误:systomIcon -> systemIcon

小拼写错误,影响可读性,顺手改一下更好。

-    const systomIcon = closeIconPosition !== 'bottom' ? <Close /> : <Failure />
+    const systemIcon = closeIconPosition !== 'bottom' ? <Close /> : <Failure />
@@
-        {React.isValidElement(closeIcon) ? closeIcon : systomIcon}
+        {React.isValidElement(closeIcon) ? closeIcon : systemIcon}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dcfd2f0 and c7fa61a.

📒 Files selected for processing (1)
  • src/packages/dialog/dialog.taro.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/packages/dialog/dialog.taro.tsx (2)
src/packages/dialog/index.taro.ts (1)
  • TaroDialogProps (9-9)
src/types/spec/dialog/taro.ts (1)
  • TaroDialogProps (8-12)
🔇 Additional comments (1)
src/packages/dialog/dialog.taro.tsx (1)

47-47: 对齐 open 入参类型:OK

将 defaultProps 断言为 TaroDialogProps 后,typeof defaultProps 即为 TaroDialogProps,open 的第二个参数随之被推断为 Partial<TaroDialogProps>,与 PR 目标一致,且不影响运行时行为。

@xiaoyatong xiaoyatong merged commit 52d84bd into jdf2e:feat_v3.x Sep 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants