首页 > 解决方案 > .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.");
});

标签: typescriptdiscord.js

解决方案


推荐阅读