Skip to content

Conversation

@dz85
Copy link

@dz85 dz85 commented Nov 22, 2025

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

为component添加类型检查,并且让当前component代码通过类型检查

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

发布说明

  • Chores
    • 更新了开发工具链配置,包括 TypeScript 验证设置和 VSCode 编辑器配置
    • 更新了 @uni-helper/uni-types 依赖至 1.0.0-alpha.7 版本
    • 添加了新的构建检查脚本以增强开发流程
    • 改进了代码类型安全性和 TypeScript 编译配置

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Nov 22, 2025

@dz85 is attempting to deploy a commit to the weisheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 22, 2025

概览

本次PR优化了项目的TypeScript类型安全和工具配置。更新了VSCode设置以增强TypeScript支持,在package.json中添加了类型检查脚本,为wd-tour组件强化了类型注解,并新增了uni模块的TypeScript配置文件。

变更

内聚体 / 文件 变更摘要
VSCode配置增强
.vscode/settings.json
新增TypeScript验证和建议操作设置;重新格式化ESLint和i18n-ally配置数组为单行格式(无语义变更)
构建脚本与依赖更新
package.json
新增check:component脚本用于TypeScript类型检查;将@uni-helper/uni-types从1.0.0-alpha.4升级至1.0.0-alpha.7
Uni模块TypeScript配置
src/uni_modules/wot-design-uni/tsconfig.json
新增TypeScript配置文件,包含ESNext目标、Node模块解析、严格类型检查和Vue编译选项配置
Tour组件类型安全强化
src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue
导入CSSProperties类型;调整useLockScroll为命名导入;为elementInfopopoverStyle等添加显式类型注解;改进handleScrolling函数签名和边界值处理逻辑

代码审查工作量评估

🎯 3 (中等复杂度) | ⏱️ ~20-25 分钟

需重点关注的区域:

  • wd-tour.vueElementRect类型的使用及其与initializeElementInfo初始化逻辑的一致性
  • handleScrolling函数新签名中scrollNeeds参数类型与调用方的兼容性验证
  • 新增tsconfig.json中的Volar插件和编译选项是否与项目其他配置协调一致
  • useLockScroll从默认导入改为命名导入的影响范围确认

可能相关的PR

建议审查人

  • Moonofweisheng

小诗一首

🐰 TypeScript的约束来临,
类型的盔甲闪闪发光,
Tour组件焕然一新,
严格检查护航航行,
代码更安全,开发更从容~ ✨

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 标题准确总结了主要改动:添加类型检查和修复wd-tour组件,与提交的所有更改直接相关。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

@netlify
Copy link

netlify bot commented Nov 22, 2025

Deploy Preview for wot-design-uni failed. Why did it fail? →

Built without sensitive environment variables

Name Link
🔨 Latest commit 0d0ffb7
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/6921c798f50eaf0008bfe169

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

🧹 Nitpick comments (1)
src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue (1)

141-160: CSSProperties 的 textAlign 键建议使用驼峰写法提升可读性

目前 popoverStyle 中声明为:

  • position: CSSProperties['position']
  • textAlign: CSSProperties['text-align']

由于 CSSProperties 本身定义了 textAlign 属性,建议将类型改为 CSSProperties['textAlign'],与接口字段保持一致,更直观一些(现在用 'text-align' 虽然也能通过索引签名得到兼容类型,但会稍显迷惑)。

这只是类型注解层面的可读性优化,不影响现有运行时行为,可视情况调整。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4aaf257 and 0d0ffb7.

📒 Files selected for processing (4)
  • .vscode/settings.json (3 hunks)
  • package.json (2 hunks)
  • src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue (5 hunks)
  • src/uni_modules/wot-design-uni/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-24T06:12:44.418Z
Learnt from: Moonofweisheng
Repo: Moonofweisheng/wot-design-uni PR: 733
File: src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue:327-327
Timestamp: 2024-11-24T06:12:44.418Z
Learning: 在 `src/uni_modules/wot-design-uni/components/wd-tabs/wd-tabs.vue` 中,由于 `title` 可能会发生变化,涉及到 `title` 的优化不太容易实现,需谨慎处理。

Applied to files:

  • src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue
🔇 Additional comments (4)
.vscode/settings.json (1)

14-25: VSCode TypeScript 校验与 i18n-ally 配置调整整体合理

启用 typescript.validate.enable / 建议操作,并显式 tsdk 与 workspace TSDK 提示,能更好地配合新加的 tsconfigvue-tsc 检查;i18n-ally 的数组改成单行只是格式变更,不影响行为,看起来都没问题。建议团队本地打开任意 TS 文件确认 VSCode 状态栏实际使用的是 workspace TypeScript 版本,以避免因为全局 TS 版本差异导致检查结果不一致。

Also applies to: 33-35, 39-40, 43-44, 52-53, 60-62, 85-85

src/uni_modules/wot-design-uni/components/wd-tour/wd-tour.vue (1)

61-61: wd-tour 类型补充与滚动逻辑收紧与 PR 目标一致

  • 引入 type CSSProperties、显式声明 ElementRect 并将 elementInfo 标注为 ref<ElementRect>,可以消除不少 vue-tsc 在可选属性上的告警。
  • initializeElementInfo / checkScrollNeeds / scrollDown 中对 res.bottom 使用 !== undefined ? res.bottom : 0 / ?? 0 的处理,比直接使用可选属性更安全,也避免了底部缺失时的 NaN 计算。
  • handleScrolling 的签名改为 scrollNeeds: ReturnType<typeof checkScrollNeeds>,能确保调用方和实现始终保持字段一致,类型层面更稳健。
  • useLockScroll 从具名导出引入,如果对应的 ../composables/useLockScroll 模块已经改为 export function useLockScroll(...),这里是更符合规范的写法。

整体看,这些改动既解决类型检查问题,又没有明显改变原有运行时行为。建议本地跑一次新加的 check:component(或现有 type-check)脚本,确认 wd-tour 在严格类型检查下无新增报错,并确认 useLockScroll 的导出形式与此处一致。

Also applies to: 64-64, 67-75, 83-88, 196-222, 237-242, 255-275, 278-311

package.json (1)

56-56: check:component 脚本与 uni-types 升级与新 tsconfig 配合良好

  • 新增 check:component 使用 vue-tsc -p ./src/uni_modules/wot-design-uni/tsconfig.json --noEmit,正好对应本次引入的局部 tsconfig,便于只对组件库做类型检查。
  • @uni-helper/uni-types 升级到 1.0.0-alpha.7,也与 tsconfig.json 里挂载的 Volar 插件保持一致,有利于获得更完整的 uni 类型支持。

建议后续考虑在 CI 或日常脚本中串联 check:component(例如在 type-check 或发布流程中调用),确保组件库的 TS 类型问题不会回归;同时在本地升级依赖后跑一遍 pnpm run check:component 与常规构建,确认新版本的 @uni-helper/uni-types 不会引入额外 breaking change。

Also applies to: 112-112

src/uni_modules/wot-design-uni/tsconfig.json (1)

1-51: 针对组件库新增的 tsconfig 配置整体合理,可支持严格类型检查

  • strict + noImplicitThisisolatedModulesjsx: "preserve"target/module: "ESNext" 等组合,对 Vue 3 + uni-app 场景是比较标准的严格配置,也契合 vue-tsc 的需求。
  • 显式开启 resolveJsonModuleuseDefineForClassFieldsesModuleInteropverbatimModuleSyntax,有助于适配现代打包链路和各类导入形式。
  • types 中引入 @dcloudio/typesmini-types@uni-helper/uni-typesminiprogram-api-typings 等,可以覆盖 uni / 小程序 多平台的全局类型,配合 vueCompilerOptions.plugins: ["@uni-helper/uni-types/volar-plugin"] 能获得较好的 IDE 体验。
  • exclude 仅排除了 node_modulesunpackage 与当前目录下的 src/**/*.nvue,与 package.jsoncheck:component 以本目录为 project root 的用法是匹配的。

整体看,这份 tsconfig 与本次 wd-tour 的类型强化、VSCode 设置以及新脚本是闭环的,只是 types 里同时写了 "node""@types/node",在大多数场景下二者等价,保留与否都可以,后续如需精简可以去掉其一。

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.

1 participant