Currently I'm getting the below error from trying to import some files as strings into my 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";
typings/glsl.d.ts:
declare module "*.glsl" {
const value: string;
export default value;
}
tsconfig:
{
"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"]
}
my folder structure:

Does anyone know why this error is occurring and how I can fix it?
I removed the "include": ["main.ts"] and now it works. I was told that adding the main.ts makes the main.ts the only file that gets compiled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With