javascript - 误报 Typescript 找不到模块警告
问题描述
我正在使用以下代码导入图标:
import Icon from "!svg-react-loader?name=Icon!../images/svg/item-thumbnail.svg"
在 Visual Studio Code 1.25.1 中,我从 tslint 收到以下警告:
[ts] 找不到模块 '!svg-react-loader?name=Icon!../images/svg/item-thumbnail.svg'。
即使我应用 tslint 忽略语句,我仍然会收到此警告:
// tslint:disable-next-line:no-implicit-dependencies
导入工作正常(即 WebPack 构建包时没有错误),但我真的很想摆脱这个警告。任何想法如何做到这一点?
解决方案
要获得 tslint,您可以这样做
import MyIcon from '!svg-react-loader?name=Icon!./down-arrow.svg'
将此用于您的 tslint.conf
{
"rules": {
"no-implicit-dependencies": [
true,
["!svg-react-loader?name=Icon!."]
]
}
}
这有点乱,但它有效..本质上,您需要将整个加载程序字符串列入白名单。
推荐阅读
- rxjs - 如何按顺序在两个 Observable 之间切换并让订阅触发两次?
- javascript - 如何根据 Google 表格中的范围自动更新 Google 表单中的下拉列表?
- visual-studio - 设置 Xamarin.Forms 和 Visual Studio 2019 以与 mac ISSUE 配对
- opencv - 使用 opencv 对手绘形状进行分类
- angular - Angular 组件的单元测试 Jasmine 问题“失败:未定义 XMLHttpRequest”
- c# - 选择第 7 个人(行)并得到 7 作为结果
- reactjs - 在测试期间从 React 自定义钩子读取属性时出错
- r - Networkd3 Sankey 图不会打印到 HTML
- html - javascript中鼠标位置的事件
- python - 如何安装 discord.py 库