nuxt / image

Plug-and-play image optimization for Nuxt applications.
https://image.nuxt.com
MIT License
1.33k stars 271 forks source link

Latest release is missing `NuxtOptions` extension #1449

Closed cjpearson closed 1 month ago

cjpearson commented 1 month ago

The following exists in dist/types.d.ts for 1.7.0 but is missing in the same file for 1.7.1

import type { ModuleOptions } from './module'

declare module '@nuxt/schema' {
  interface NuxtConfig { ['image']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['image']?: ModuleOptions }
}

declare module 'nuxt/schema' {
  interface NuxtConfig { ['image']?: Partial<ModuleOptions> }
  interface NuxtOptions { ['image']?: ModuleOptions }
}

This causes a type error when a setup function tries to modify the Nuxt Image config.

async setup(options, nuxt) {
  nuxt.options.image = {...} // error TS2339: Property 'image' does not exist on type 'NuxtOptions'.
}
flav-code commented 1 month ago

I don't know if it's related, but in 1.7.1 my images no longer have the width and height attributes.

danielroe commented 1 month ago

This was removed from @nuxt/module-builder output and should be added instead by .nuxt/types/schema.d.ts. What version of Nuxt are you on?

github-actions[bot] commented 1 month ago

Would you be able to provide a reproduction? 🙏

More info ### Why do I need to provide a reproduction? Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making. ### What will happen? If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect. If `needs reproduction` labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it. ### How can I create a reproduction? We have a template for starting with a minimal reproduction: 👉 https://stackblitz.com/github/nuxt/image/tree/main/example A public GitHub repository is also perfect. 👌 Please ensure that the reproduction is as **minimal** as possible. See more details [in our guide](https://nuxt.com/docs/community/reporting-bugs/#create-a-minimal-reproduction). You might also find these other articles interesting and/or helpful: - [The Importance of Reproductions](https://antfu.me/posts/why-reproductions-are-required) - [How to Generate a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve)
cjpearson commented 1 month ago

We're using nuxt@3.11.2

cjpearson commented 1 month ago

The error occurs in an app-local module, so I've made a small reproduction app with a local module.

https://github.com/cjpearson/nuxt-image-types

The type error is in modules/my-module/index.ts and disappears once @nuxt/image is downgraded to 1.7.0