-
-
Notifications
You must be signed in to change notification settings - Fork 323
fix: 🐛 add type-check and fix wd-tour #1376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@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. |
概览本次PR优化了项目的TypeScript类型安全和工具配置。更新了VSCode设置以增强TypeScript支持,在package.json中添加了类型检查脚本,为wd-tour组件强化了类型注解,并新增了uni模块的TypeScript配置文件。 变更
代码审查工作量评估🎯 3 (中等复杂度) | ⏱️ ~20-25 分钟 需重点关注的区域:
可能相关的PR
建议审查人
小诗一首
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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.
Example instruction:
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. Comment |
❌ Deploy Preview for wot-design-uni failed. Why did it fail? →Built without sensitive environment variables
|
There was a problem hiding this 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
📒 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 提示,能更好地配合新加的tsconfig和vue-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+noImplicitThis、isolatedModules、jsx: "preserve"、target/module: "ESNext"等组合,对 Vue 3 + uni-app 场景是比较标准的严格配置,也契合vue-tsc的需求。- 显式开启
resolveJsonModule、useDefineForClassFields、esModuleInterop与verbatimModuleSyntax,有助于适配现代打包链路和各类导入形式。types中引入@dcloudio/types、mini-types、@uni-helper/uni-types、miniprogram-api-typings等,可以覆盖 uni / 小程序 多平台的全局类型,配合vueCompilerOptions.plugins: ["@uni-helper/uni-types/volar-plugin"]能获得较好的 IDE 体验。exclude仅排除了node_modules、unpackage与当前目录下的src/**/*.nvue,与package.json中check:component以本目录为 project root 的用法是匹配的。整体看,这份 tsconfig 与本次 wd-tour 的类型强化、VSCode 设置以及新脚本是闭环的,只是
types里同时写了"node"与"@types/node",在大多数场景下二者等价,保留与否都可以,后续如需精简可以去掉其一。
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
无
💡 需求背景和解决方案
为component添加类型检查,并且让当前component代码通过类型检查
☑️ 请求合并前的自查清单
Summary by CodeRabbit
发布说明
✏️ Tip: You can customize this high-level summary in your review settings.