tamakipedia

フロントエンドエンジニア。Typescriptもう特訓中です。一日の振り返りや学んだことをちょっとずつ吐いています。

【Typescript】モジュール 'styles/***.css' またはそれに対応する型宣言が見つかりません。

typescriptに scss を import しようとするとエラーになってしまう。

解決

next-env.d.tsファイルに以下を追記

//make it possible to import scss file
declare module '*.css';
// or scss
declare module '*.scss';

これで import が可能になります。

参考:How to fix TypeScript cannot find module CSS/SCSS in Next.js