fix(types): accept all configured providers in Img interface#2175
fix(types): accept all configured providers in Img interface#2175
Conversation
The Img interface call signature used ImageOptions without a generic
parameter, defaulting to DefaultProvider ("ipx"). This caused
TS2322 errors when passing any non-default provider (e.g. "directus")
to useImage() options, even when the provider is properly configured
in nuxt.config.ts.
Widen the provider type to keyof ConfiguredImageProviders so all
configured providers are accepted.
Fixes nuxt#2174
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
commit: |
|
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)
📝 WalkthroughWalkthroughThis change fixes a TypeScript type issue in the image module where Img-related methods only accepted the default image provider in their options parameter. The fix widens the type parameter from a default-provider-only restriction to accept all configured image providers. The callable Img interface, getImage, getSizes, and getMeta methods are updated to use Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip CodeRabbit can generate a title for your PR based on the changes.Add |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2175 +/- ##
=======================================
Coverage 32.52% 32.52%
=======================================
Files 7 7
Lines 372 372
Branches 131 131
=======================================
Hits 121 121
Misses 194 194
Partials 57 57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Imginterface call signature usesImageOptionswithout a generic parameter, defaulting toDefaultProvider("ipx")TS2322when passing any non-default configured provider (e.g."directus") touseImage()optionsprovidertype inImgtokeyof ConfiguredImageProvidersso all configured providers are acceptedReproduction
Fix
Changed
ImageOptions→ImageOptions<keyof ConfiguredImageProviders>in theImginterface (call signature,getImage,getSizes,getMeta).Fixes #2174
🤖 Generated with Claude Code