我该如何解决这个打字稿错误?
我在下面的行中收到错误。
常量自我=这个;
我在终端中收到如下错误:
错误“this”意外别名为局部变量@typescript-eslint/no-this-alias
请找到下面的代码:
notifyOwner(req, metadata, callback) {
const currentUserId = req.session.identity.individual.userName;
const docId = metadata.docId;
let message = this.templates.selfRemoval;
const self = this;
const targetUserId = metadata.ownerId;
const paperTitle = metadata.title.replace(/<(.|\n)*?>/g, '');
const nonOwnerRole = metadata.userRole;
message = message.replace(/\[CollaboratorName\]/g, req.session.identity.individual.firstName + ' ' + req.session.identity.individual.lastName);
message = message.replace(/\[NonOwnerRole\]/g, (nonOwnerRole === 'author') ? 'collaborator' : 'reviewer');
message = message.replace(/\[PaperTitle\]/g, paperTitle);
const eventData = {
message: message,
objectType: 'manuscript',
objectId: docId
};
self.createEvent(currentUserId, targetUserId, eventData, (err, result) => { …Run Code Online (Sandbox Code Playgroud)