I have a ts(2307) error when I import some jpg files from my src folder and vsc warns that ‘Cannot find module or its corresponding type declarations.’
Though, my code compiled and run well, but I don’t want to see the warning messages.
According to some references on the Google, it seems related to tsconfig.json file, but I’m very new to this typescript area … so..
Here is my code where the error comes out
import splashImg from '../assets/images/splashImg.jpg';
import naverLogin from '../assets/images/naverLogin.jpg';
import appleLogin from '../assets/images/appleLogin.jpg';
and Here is my tsconfig.json file
{
"compilerOption" : {
"target" : "esnext",
"module" : "commonjs",
"lib" : ["es2017"],
"allowJs" : true,
"jsx" : "react-native",
"noEmit" : true,
"strict" : true,
"moduleResolution" : "node",
"allowSyntheticDefaultImports" : true,
"esModuleInterop" : true,
"skipLibCheck" : false,
"resolveJsonModule" : true
},
"exclude" : ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}
Thank you for your time, and thank you in advance.
Please Help 🙁
2
Answers
change it to
change path according to your directory structure. if not work please share your project repo hierarchy
in most baseline projects like nextjs or create-react-app you can simply add global.t.ds file in which you’ll be able to declare (and tell) typescript compiler "Hey! this type of file are perfectly fine modules to be consumed, no need to complain, Thanks!"