fix: 🐛 修复web-types可选值/默认值类型识别错误#899
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次 PR 主要对多个组件的文档进行修改,统一更新了属性类型描述的格式(由管道符“|”改为斜杠“/”),调整部分属性的类型定义。特别是在 Cell 组件中,将 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户输入
participant R as reWebTypesType
participant G as getPureValue
participant A as reAttribute
U->>R: 传入原始类型字符串
R->>G: 清理字符串 (去除反引号、星号及引号)
G-->>R: 返回净化后的字符串
R->>R: 进行类型检查与验证
R-->>U: 返回处理后的类型
U->>A: 传入属性值(包含 v-model 相关信息)
A->>A: 检查并处理 v-model 条件
A-->>U: 返回格式化后的属性值
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for wot-design-uni ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
scripts/build-web-types.ts (1)
85-104: 建议增强错误处理机制当前实现已经很好地处理了 v-model 和可选值,但建议添加以下改进:
- 对
value进行空值检查- 添加对特殊字符的处理日志
建议的实现方式:
if (title.includes('Attributes')) { + if (!value) { + console.warn('Empty value detected in attributes') + return undefined + } if (key === '参数') { if (value.includes('v-model:')) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
docs/component/cell.md(1 hunks)docs/component/circle.md(1 hunks)docs/component/index-bar.md(1 hunks)docs/component/password-input.md(1 hunks)docs/component/progress.md(1 hunks)docs/component/segmented.md(1 hunks)docs/component/sidebar.md(2 hunks)docs/component/status-tip.md(1 hunks)docs/component/swiper.md(1 hunks)docs/component/textarea.md(1 hunks)scripts/build-web-types.ts(2 hunks)
✅ Files skipped from review due to trivial changes (6)
- docs/component/textarea.md
- docs/component/password-input.md
- docs/component/progress.md
- docs/component/circle.md
- docs/component/segmented.md
- docs/component/sidebar.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Redirect rules - wot-design-uni
- GitHub Check: Header rules - wot-design-uni
- GitHub Check: Pages changed - wot-design-uni
🔇 Additional comments (11)
scripts/build-web-types.ts (2)
46-52: 代码实现清晰简洁!
getPureValue函数实现了字符串清理的核心功能,能有效处理反引号、星号和引号,使类型识别更准确。
56-64: 类型处理逻辑优化合理!通过整合
getPureValue函数,改进了类型识别的准确性,同时保持了原有的类型处理逻辑。docs/component/status-tip.md (1)
81-82: 类型表示方式统一化,文档更清晰!将类型表示从
string | number改为string / number使文档格式更统一,提高了可读性。docs/component/index-bar.md (1)
300-300: 文档格式统一更新完成!类型表示方式的更新与项目其他文档保持一致,提升了整体文档的一致性。
docs/component/cell.md (1)
236-236:Details
❓ Verification inconclusive
类型定义优化及表单功能增强!
- 将
border属性类型改为boolean更符合实际使用场景- 新增
prop属性支持表单验证,增强了组件的实用性建议验证这些改动在现有代码中的兼容性。
Also applies to: 256-258
🏁 Script executed:
#!/bin/bash # 检查现有代码中的 border 属性使用情况 rg "border\s*=" --type vueLength of output: 56
请手动验证 border 属性的使用情况与表单功能增强改动
当前文档中(docs/component/cell.md,第236行及对应的256-258行)已将
border属性的类型修改为boolean,并新增了支持表单验证的prop属性。这些改动对类型安全和组件实用性都有所提升,但请注意手动检查代码库中 vue 文件对border属性的使用情况,以确保不会引入兼容性问题。建议使用以下脚本重新验证 vue 文件中
border属性的使用情况(注意:避免使用未识别的 vue 文件类型,因此采用基于文件扩展名的筛选):#!/bin/bash # 检查 vue 文件中 border 属性的使用情况 rg "border\s*=" -g "*.vue"docs/component/swiper.md (6)
312-312: 更新 “height” 属性类型描述格式
此处将旧的string | number改为string / number,符合本次文档统一使用斜杠分隔的格式,使类型说明更直观且保持整个文档风格一致。
314-314: 更新 “list” 属性类型描述格式
将string[] | SwiperList[]修改为string[] / SwiperList[],与其它属性的类型描述保持一致,提升了文档的一致性和可读性。
316-316: 更新 “nextMargin” 属性类型描述
通过将类型描述由string | number改为string / number,统一了文档中类型分隔符的风格,建议保持所有相关属性格式统一。
318-318: 更新 “previousMargin” 属性类型描述
同样使用斜杠(/)分隔类型,和其它更新保持一致,文档风格更加统一。
320-320: 更新 “indicator” 属性类型描述
将SwiperIndicatorProps | boolean更正为SwiperIndicatorProps / boolean,保证了整个文档展示的类型说明格式统一,便于用户理解。
328-328: 更新 “adjust-height” 属性类型描述
新的类型写法'first' / 'current' / 'highest' / 'none'清晰列举了可选值,能更好地指导用户使用。请确认示例及说明与组件实现保持一致。
🤔 这个 PR 的性质是?(至少选择一个)
🔗 相关 Issue
#819
💡 需求背景和解决方案
目前 web-types 将
-识别成了有效的值,导致大多数属性的值被当作 enum 类型,webstorm 会提示很多类型不匹配的警告。这个 PR 将-、—、*等其他值过滤掉,同时修改统一了文档中部分类型的分隔符,从而修复该问题。☑️ 请求合并前的自查清单
Summary by CodeRabbit