![](/img/trans.png)
[英]TS2307: Cannot find module '@/*' or its corresponding type declarations
[英]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.