fix(types): 补充 setStorage 支付宝平台返回类型定义#19248
Conversation
支付宝小程序下 setStorage 返回 `{ success: true }`,补充对应的
SuccessCallbackResult 类型定义,标记为 @supported alipay。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough新增 CLI 模板的 变更环境配置模板集成
存储 API 类型定义适配
代码审核工作量🎯 2 (Simple) | ⏱️ ~10 分钟 诗
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/taro-cli/templates/default/_env.example (1)
1-3: 💤 Low value考虑补充更多常用环境变量示例。
当前模板仅包含
TARO_APP_ID一个示例。可以考虑添加更多 Taro 项目中常用的环境变量(如 API 基础 URL、调试开关等),帮助用户更快理解环境配置的用途。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/taro-cli/templates/default/_env.example` around lines 1 - 3, The template only shows TARO_APP_ID; add several common example environment variables with short inline descriptions so users understand usage: include variables like API_BASE_URL (backend base URL), NODE_ENV (development|production), DEBUG or LOG_LEVEL (toggle verbose logs), FEATURE_FLAGS or FEATURE_<NAME> (feature toggles), ANALYTICS_KEY or SENTRY_DSN (monitoring), and optional MOCK_API=true/false; update the _env.example near the TARO_APP_ID entry to list these keys with placeholder values and brief comments explaining each one.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/taro/types/api/storage/index.d.ts`:
- Around line 30-35: The current SuccessCallbackResult extends
TaroGeneral.CallbackResult which forces errMsg to be required; change
SuccessCallbackResult to remove the required errMsg from the base and
reintroduce it as optional (e.g. use Omit<TaroGeneral.CallbackResult, "errMsg">
then add errMsg?: string and success?: boolean) so the Alipay setStorage success
callback type no longer requires errMsg; update the declaration named
SuccessCallbackResult accordingly.
---
Nitpick comments:
In `@packages/taro-cli/templates/default/_env.example`:
- Around line 1-3: The template only shows TARO_APP_ID; add several common
example environment variables with short inline descriptions so users understand
usage: include variables like API_BASE_URL (backend base URL), NODE_ENV
(development|production), DEBUG or LOG_LEVEL (toggle verbose logs),
FEATURE_FLAGS or FEATURE_<NAME> (feature toggles), ANALYTICS_KEY or SENTRY_DSN
(monitoring), and optional MOCK_API=true/false; update the _env.example near the
TARO_APP_ID entry to list these keys with placeholder values and brief comments
explaining each one.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2124656d-b993-4961-8eea-ffe63390e2e5
📒 Files selected for processing (4)
packages/taro-cli/templates/default/_env.examplepackages/taro-cli/templates/default/_gitignorepackages/taro-cli/templates/default/template_creator.jspackages/taro/types/api/storage/index.d.ts
|
不只是 Taro.setStorage 这一个方法,其他的使用 TaroGeneral.CallbackResult 的接口也存在这样的问题吧 |
确实,这个问题不只存在于 Taro.setStorage。根因是 我看了一下,目前 我倾向于后续改成一个通用类型,例如为支付宝这类结果新增 |
@Jarvis636431 其实新增返回类然后用 | 来表达其实还是不合适,那用 Taro 的开发者再去手动适配这个success 吗? 隔壁的 Uni 对于跨平台适配的理解我觉得是对的。框架内部去消化不同平台出入参的差异性,然后跨端平台提供出来的接口,都是跨端平台自己定义的出入参数据格式。比如我在 #19216 提到的 uni.requestPayment,再比如uni.getLocation Taro 如果不尽早修正,沉没成本会越来越高....我现在都有点不想用 Taro 了,因为 Taro 根本就没有做到跨端适配 |
哎,是的,现在已经是高度绑定微信生态,对于其他平台的适配只是额外增加 api 并不合适,框架本身应该是简化开发者负担的,同样的行为需要同样的 api 定义,而不是一个平台新增一个 api,除非做好语义化 |
Summary
Taro.setStorage的类型定义仅包含errMsg字段,但支付宝小程序下实际返回{ success: true }setStorage.SuccessCallbackResult接口,扩展success?字段并标记为@supported alipayChanges
packages/taro/types/api/storage/index.d.tssetStorage.SuccessCallbackResult extends TaroGeneral.CallbackResultOption.success回调参数类型更新setStorage()返回值更新为Promise<setStorage.SuccessCallbackResult>Related
🤖 Generated with Claude Code
Summary by CodeRabbit
发行说明
文档
改进