Object is possibly 'undefined'
I'm getting a lot of errors for typescript in nuxt image. I am using nuxt v4 compatibility mode if that makes a difference
ERROR(vue-tsc) Object is possibly 'undefined'.
FILE /Users/zesty/Code/xxx-frontend/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@nuxt/image/dist/runtime/components/NuxtPicture.vue:20:16
18 | :src="sources[lastSourceIndex].src"
19 | :sizes="sources[lastSourceIndex].sizes"
> 20 | :srcset="sources[lastSourceIndex].srcset"
| ^^^^^^^^^^^^^^^^^^^^^^^^
21 | >
22 | </picture>
23 | </template>
I’m hitting the same issue, and I believe it’s related to the latest release v3.13.0. It seems that there were changes in the types, which might be causing this problem. I found this Vue TypeScript Changes that mentions updates to TypeScript handling, but I’m still unsure how to resolve the issue.
I think this is an upstream issue then.
@danielroe what would be your opinion? :)
it's not an upstream issue, but it was resolved in https://github.com/nuxt/image/commit/917242a567ffbbb3cd6cf467322252a5cf9194f4.
thanks for investigating! ❤