-
Notifications
You must be signed in to change notification settings - Fork 284
fix: throw error should not block the export of component #2996
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
Conversation
Walkthrough此次变更移除了对不支持 TARO_ENV 环境抛出错误的处理,而是采用了回退实现。对于非 "h5" 和 "weapp" 环境,组件不再报错,而是返回其子组件。为兼容新的逻辑,代码中添加了 TypeScript 忽略注释,其余导出接口保持不变。 Changes
Sequence Diagram(s)sequenceDiagram
participant L as Lottie 组件
participant I as 实现逻辑
L->>I: 调用渲染逻辑
Note right of I: 检查 TARO_ENV 环境变量
alt TARO_ENV 为 "h5" 或 "weapp"
I->>L: 使用原始实现(如 LottieWeb 或 LottieMp)
else 非支持环境
I->>L: 使用回退实现,返回 props.children
end
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 (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feat_v3.x #2996 +/- ##
==========================================
Coverage 85.79% 85.79%
==========================================
Files 281 281
Lines 18527 18527
Branches 2810 2810
==========================================
Hits 15896 15896
Misses 2626 2626
Partials 5 5 ☔ View full report in Codecov by Sentry. |
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 (3)
src/packages/lottie/index.taro.ts (3)
8-8
: 建议使用更安全的类型断言方式当前使用
@ts-ignore
来忽略类型检查可能会掩盖潜在的类型问题。建议考虑使用更明确的类型断言方式。- // @ts-ignore + implementation = LottieWeb as ComponentType<Partial<LottieProps>> - // @ts-ignore + implementation = LottieMp as ComponentType<Partial<LottieProps>>Also applies to: 11-11
14-18
: 建议添加警告信息移除错误抛出的修改符合需求,但建议添加警告信息以便于调试。
// throw new Error(`不支持的 TARO_ENV: ${process.env.TARO_ENV}`) + console.warn(`当前环境 ${process.env.TARO_ENV} 不支持 Lottie 组件,将只渲染子组件`) implementation = (props: any) => { return props.children }
15-17
: 建议改进类型定义当前回退实现使用
any
类型,建议定义更具体的类型以提高代码的可维护性。- implementation = (props: any) => { + implementation = (props: Partial<LottieProps>) => { return props.children }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/packages/lottie/index.taro.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
Summary by CodeRabbit