我有以下代码:

    _.remove(this.home.modal.data.roles, function (currentObject) {
        return currentObject.name === roleToDelete;
    });


有人可以告诉我如何将函数调用更改为通常用Typescript完成的方式。也给我一个错误:

    Message 118 TsLint: expected callSignature to have a typedef.


任何建议,将不胜感激。

最佳答案

这是您要找的东西吗?

_.remove(this.home.modal.data.roles, (currentObject) => {
    return currentObject.name === roleToDelete;
});


您也可以像这样输入“ currentObject”:

_.remove(this.home.modal.data.roles, (currentObject: Role) => {
    return currentObject.name === roleToDelete;
});

10-07 12:39