typescript - .startsWith 在使用打字稿时抛出错误
问题描述
每当我使用.startsWith()
时,它都会给我这个错误:
Property 'startsWith' does not exist on type 'string'.
如果我试穿它会起作用.startsWith()
,index.js
但不是index.ts
。
这是我所拥有的:
client.on("message", function (msg) {
if (msg.author.bot) {
return;
}
if (!msg.content.startsWith(ConfigFile.config.prefix)) {
return;
}
msg.channel.send(msg.author.username + " this better work.");
});
解决方案
推荐阅读
- python-3.x - 未获取 SQLAlchemy OperationalError
- php - 对数据库中的每个数据进行数学运算 sql 将结果发布到 php 中的数据库
- objective-c - 如何覆盖 PDFAnnotation IOS-PDFKIT 上的绘制方法
- java - Spring boot 自定义 Jackson 序列化以返回对象而不是附加类型
- swift - Xcode 跳过 if else 语句
- django - Django 动态表单 - 创建选择小部件的问题(下拉菜单)
- javascript - 未捕获的 SyntaxError:Html 按钮中的标记无效或意外
- python - Coverage.py 仅在导入期间检测调用,而不是在测试执行期间检测调用
- html - Bootstrap 4.5 如何更改容器网格间距宽度
- android - Flutter 插件 gradle 子项目未由外部应用程序项目解析