category:
Technology
Back to Blog Index
ReactをCursorで開くと赤い波線が表示される時の対処法

Google AI Studioなどで作った、Next.js + Reactのファイルを開いたときに、こういう感じに赤い波線が表示される場合は、Problemsタブに以下のようなエラーがあると思います。
Could not find a declaration file for module ‘react’
JSX element implicitly has type ‘any’ because no interface ‘JSX.IntrinsicElements’ exists
React の型定義をインストールする必要があるため、以下を実行します。
npm install react react-dom
npm install -D typescript @types/react @types/react-dom