0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TypeScript).glslファイルインポート時の「型宣言が見つかりません」のエラーの解決方法

Last updated at Posted at 2024-11-02

概要

.tsファイルで.glslファイルをインポートしたら、「型宣言が見つかりません」のエラーが出たので、そのエラー内容と解決方法です。

エラー内容

エラー内容
import vertexShader from "./shaders/vertexShader.glsl";
import fragmentShader from "./shaders/fragmentShader.glsl";

モジュール './shaders/vertexShader.glsl' またはそれに対応する型宣言が見つかりません
モジュール './shaders/fragmentShader.glsl' またはそれに対応する型宣言が見つかりません

解決方法

.glslファイルと同階層に以下の記述をした.tsファイルを作成。
するとインポート元の.tsファイルでエラーの赤線は消えていました。

shaders.d.ts
declare module "*.glsl" {
  const content: string;
  export default content;
}

おわりに

aiで聞いたら解決方法がすぐ出ましたが、よく遭遇しそうなので残しておきます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?