image icon indicating copy to clipboard operation
image copied to clipboard

fix(types): add ProviderDefaults to fix provider type resolution

Open kaki0704 opened this issue 1 month ago โ€ข 5 comments

resolves #2014

๐Ÿ”— Linked issue

resolves #2014

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation or readme)
  • [x] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

The ProviderDefaults interface was missing from src/index.d.ts, causing DefaultProvider type to resolve to never during development.

This happened because in src/types/image.ts, the DefaultProvider type is defined as:

type DefaultProvider = ProviderDefaults extends Record<'provider', unknown> ? ProviderDefaults['provider'] : never

Without ProviderDefaults.provider being defined, the conditional type resolves to never, breaking provider type inference.

Changes:

  • Added ProviderDefaults interface with provider: 'ipx' to src/index.d.ts
  • Removed unused @ts-expect-error directives from tests (now that types work correctly)

Testing:

  • pnpm test:types passes
  • Unit tests pass

kaki0704 avatar Dec 06 '25 20:12 kaki0704

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/image@2056

commit: 53ed7ec

pkg-pr-new[bot] avatar Dec 06 '25 20:12 pkg-pr-new[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 6.99%. Comparing base (9fc971d) to head (53ed7ec). :warning: Report is 3 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #2056   +/-   ##
=====================================
  Coverage   6.99%   6.99%           
=====================================
  Files         78      78           
  Lines       3629    3629           
  Branches     140     140           
=====================================
  Hits         254     254           
  Misses      3326    3326           
  Partials      49      49           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Dec 06 '25 20:12 codecov-commenter

Thank you for taking the time to review and for the helpful feedback! ๐Ÿ™ I've updated the PR to only modify src/types/image.ts.

kaki0704 avatar Dec 08 '25 13:12 kaki0704

I've taken another look. Not entirely sure I got it right, but I added provider: 'ipx' to ProviderDefaults in src/types/module.ts.

Could you please check if this is the correct approach?๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ

kaki0704 avatar Dec 08 '25 22:12 kaki0704

I don't think this is right either. that interface is populated dynamically via types that nuxt generates, which should certainly include ipx

danielroe avatar Dec 08 '25 22:12 danielroe