Cannot find name 'StaticImageData' with Typescript
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.13.2
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.1.4
react: 17.0.2
react-dom: 17.0.2
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I am using the type StaticImageData
provided by Next Typescript types.
But when compiling with TSC the application, I get: Cannot find name 'StaticImageData' with Typescript
This bug has already occurred in version 12.1.1
. My last working version is 12.1.0
.
Expected Behavior
Should not throw an error for using this type.
To Reproduce
version ^12.1.1
is required.
I have this file in root: next-env.d.ts
:
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
which is also included in my tsconfig.json
file:
"include": ["next-env.d.ts"],
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cannot find name 'StaticImageData'. · Issue #29788 - GitHub
The following error occurs during type checking. node_modules/next/dist/client/image.d.ts:19:14 - error TS2304: Cannot find name ' ...
Read more >Next.js - Type error: Cannot find name 'StaticImageData'
Failed to compile. ./node_modules/next/dist/client/image.d.ts:19:14 Type error: Cannot find name 'StaticImageData'. I tried rolling back the ...
Read more >TypeScript error TS2304 cannot find name require - Edureka
The error that I'm getting is the "TS2304: Cannot find name 'require' " when I attempt to transpile a simple TypeScript Node.js page....
Read more >Using SVGs with Next.js 11 and TypeScript - Duncan Leung
Problem: SVG TypeScript ESLint errors on value After updating to Next.js 11 (from v10.2.3 to v11.0.1) I noticed that TypeScript was having…
Read more >next/image - Next.js
This section describes the most commonly-used properties of the Image component. Find details about more rarely-used properties in the Advanced Props section.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added all the reproduction needed. I just using this type without any import. Because inserting this one: “include”: [“next-env.d.ts”], makes it work (or at-least should)
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.