typescript - 错误 TS2307:找不到模块 '.shaders/vertex.glsl' 或其对应的类型声明
问题描述
目前,我尝试将一些文件作为字符串导入到我的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
唯一可以编译的文件。
推荐阅读
- json - PLSQL 中的嵌套 JSON 对象
- excel - 动态行选择
- java - Java 8:如何使用流从 Java 8 中的 HashMap 的 ArrayList 中提取 HashMap?
- c - 为什么我使用 MPI_Bcast 和 -O3 编译器标志会收到堆栈粉碎错误,但没有 -O3 一切正常?
- java - Powemock 无法模拟依赖类不存在的类
- pandas - 如何找到两个值之间的唯一值范围并填写
- python - Python,DataFrame 的元素明智排序
- python - 如何从 python 和 BeautifulSoup 中的 html 表中抓取 url
- c# - 在应用程序配置中指定 ssl ca 和密钥 c# mysql 连接字符串
- c# - 这到底是怎么回事