question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find name 'StaticImageData' with Typescript

See original GitHub issue

Verify 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:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tal-rofecommented, Apr 4, 2022

It looks like #34394 caused some kind of regression, which was introduced in 12.1.1

I am trying import type { StaticImageData } from "next/image"

that seems to work fine. Could you add a code snippet of how are you trying to use StaticImageData?

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)

0reactions
github-actions[bot]commented, May 5, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found