-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find name 'StaticImageData'. #29788
Comments
what does your |
@stefanprobst
And my
|
- the img attribute in the interface will work as is. there seems to be a casting bug with next.js: vercel/next.js#29788
* image container created - the img attribute in the interface will work as is. there seems to be a casting bug with next.js: vercel/next.js#29788 * images added to pages
Related: https://stackoverflow.com/questions/69722076/next-js-type-error-cannot-find-name-staticimagedata Could anyone create a reproduction of this issue so we can investigate? 🙏 |
So, you can add
|
@timneutkens @leerob I was able to reproduce when updating Next to v12.0.5 or above Reproduction steps:
Result: node_modules/next/dist/client/image.d.ts:19:14 - error TS2304: Cannot find name 'StaticImageData'.
19 default: StaticImageData;
~~~~~~~~~~~~~~~
node_modules/next/dist/client/image.d.ts:21:45 - error TS2304: Cannot find name 'StaticImageData'.
21 declare type StaticImport = StaticRequire | StaticImageData;
~~~~~~~~~~~~~~~
Found 2 errors. |
This comment has been minimized.
This comment has been minimized.
I just upgraded today because of the critical issue and had the same problem in Next v12.0.7. I was able to build my project by adding this: export declare type StaticImageData = {
src: string;
height: number;
width: number;
placeholder?: string;
}; Directly in I will try to investigate a bit more tomorrow if I can pinpoint the exact change that caused this. |
Did not update Next.js as there is a build breaking issue being investigated: vercel/next.js#29788
I believe this change might be related: #28316 Using @nbouvrette's repo, I bisected the releases and found that the issue was introduced in |
@balazsorban44 I was actually bisecting on my end as well :) good find, I confirm that I am not sure exactly which part of that change is causing this in I'm also a bit surprised that this is the only issue on this topic given that Also, I found a workaround:
// Workaround related to: https://github.com/vercel/next.js/issues/29788
declare type StaticImageData = {
src: string;
height: number;
width: number;
placeholder?: string;
};
|
Update Next.js to latest version, but had to implement a workaround related to vercel/next.js#29788
I have the same issue, a reproduction can be found in this repository: https://github.com/TheComputersClub/teampost/commit/0c6b289deada6437b843978fb2421b7fb33f22f7 |
Is anyone still experiencing this issue? I can't reproduce this, and based on the lack of activity in this issue I'm thinking it's probably fixed. I'll close in a day or two unless I hear otherwise. |
@atcastle yes - easy to reproduce using
Voilà: $ npm run build
> next-multilingual@0.10.3 build
> rm -Rf ./lib && tsc
node_modules/next/dist/client/image.d.ts:19:14 - error TS2304: Cannot find name 'StaticImageData'.
19 default: StaticImageData;
~~~~~~~~~~~~~~~
node_modules/next/dist/client/image.d.ts:21:45 - error TS2304: Cannot find name 'StaticImageData'.
21 declare type StaticImport = StaticRequire | StaticImageData;
~~~~~~~~~~~~~~~
Found 2 errors. |
@nbouvrette Thanks, I was able to reproduce with that. @lfades it looks like this issue was introduced by your change in #28316. Could you take a look at this? |
Which *.d.ts file did you insert your workaround into? |
@unknownbreaker I used
Hope that helps 🍻 |
|
I dug through the source of the PR that closed this issue and everything looks good, I just wasn't ready to switch to |
It's fine, I just wanted to point out to the next person reading that there is no need for hacks anymore, as this has been fixed in Next.js already. 👍 |
I get that for sure, but I think a lot of folks may not want to switch to a |
@balazsorban44 Unfortunately, I can't use |
@SpencerKaiser Do you have to manually change the |
The next time someone runs |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
11.1.2 & 11.1.3-canary.57
What version of Node.js are you using?
14.16.0
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
next build
Describe the Bug
The following error occurs during type checking.
I got the following Issue in v11.0.0, upgraded to v11.1.2 and the problem was solved, but now I get this error instead.
#26892
Expected Behavior
TS compiler should not give errors.
To Reproduce
Here's the full code to my component:
The text was updated successfully, but these errors were encountered: