【发布时间】:2022-02-13 19:01:05
【问题描述】:
我正在尝试在我的 typescript react 项目中导入 png,如下所示:import logo from 'assets/Logo.svg';
我收到了这个 TS 错误:Cannot find module 'assets/Logo.svg' or its corresponding type declarations.ts(2307)
知道这是为什么吗?我在下面附上了我的tsconfig.json 文件,以防我配置错误:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "src"
},
"include": ["src"]
}
【问题讨论】:
-
这能回答你的问题吗? Unable to import svg files in typescript
标签: reactjs typescript