簡體   English   中英

錯誤 TS2307:找不到模塊 '.shaders/vertex.glsl' 或其對應的類型聲明

[英]error TS2307: Cannot find module '.shaders/vertex.glsl' or its corresponding type declarations

目前,我嘗試將一些文件作為字符串導入到我的main.ts中時遇到以下錯誤。

main.ts:2:21 - error TS2307: Cannot find module './shaders/vertex.glsl' or its corresponding type declarations.
main.ts:3:21 - error TS2307: Cannot find module './shaders/fragment.glsl' or its corresponding type declarations.

main.ts:

// shader
import vsource from ".shaders/vertex.glsl";
import fsource from ".shaders/fragment.glsl";

打字/glsl.d.ts:

declare module "*.glsl" {
    const value: string;
    export default value;
}

配置:

{
    "compilerOptions": {
        /* Visit https://aka.ms/tsconfig.json to read more about this file */

        /* Basic Options */
        "target": "es5",
        "lib": [
            "es2019",
            "dom"
        ] ,
        "allowJs": false,
        "declaration": true,
        "sourceMap": true,
        "outDir": "./dist/",
        "strict": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "strictFunctionTypes": true,
        "strictBindCallApply": true,
        "strictPropertyInitialization": true,
        "noImplicitThis": true,
        "alwaysStrict": true,

        "noUnusedLocals": false,      
        "noUnusedParameters": false,  
        "noImplicitReturns": true,
        "noFallthroughCasesInSwitch": true ,
        "typeRoots": [
            "./typings"
        ],
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "skipLibCheck": true,
        "forceConsistentCasingInFileNames": true 
    },
    "compileOnSave": true,
    "include": ["main.ts"]
}

我的文件夾結構:

我的文件夾結構

有誰知道為什么會發生此錯誤以及如何解決?

我刪除了"include": ["main.ts"]現在它可以工作了。 有人告訴我,添加main.ts會使main.ts成為唯一被編譯的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM