feat!: typed providers + modifiers#1802
Merged
Merged
Conversation
commit: |
Deploying nuxt-image with
|
| Latest commit: |
bc1e148
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://db0666bd.nuxt-image.pages.dev |
| Branch Preview URL: | https://feat-typed-providers.nuxt-image.pages.dev |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1802 +/- ##
==========================================
+ Coverage 63.09% 63.12% +0.03%
==========================================
Files 79 77 -2
Lines 3785 3824 +39
Branches 434 442 +8
==========================================
+ Hits 2388 2414 +26
- Misses 1371 1384 +13
Partials 26 26 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
atinux
approved these changes
Apr 8, 2025
atinux
left a comment
Member
There was a problem hiding this comment.
Really good changes IMO, I like the defineProvider util!
I let you fix conflicts with pnpm lock before merging of course 😄
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
❓ Type of change
📚 Description
This adds strong typing for image providers + modifiers throughout, including in the image module options. (For example, a provider that requires you set a baseURL will enforce that in the nuxt config.
This is a breaking change because image providers are now no longer using named exports but a single default export wrapped in a
defineProviderfunction (which can also have an optional setup function).I've also done quite a lot of cleaning up of types elsewhere, and dropped image props that we weren't using - they should be fine to be attributes inherited by the
<img>element.The next steps will need to be actually getting and setting the types for provider modifiers. (As an interim fix we can support key signatures
[key: string]: string | numberthat would allow the same permissive approach that's working at the moment.)Because types live in the individual provider files, it should be easy for users to add their own types for custom providers - and also to keep the types in sync for future providers + updates to existing ones.