Skip to main content
1 de 2
Rafael Costa
  • 374
  • 1
  • 4
  • 14

Tratar promise com typescript

Eu tenho o seguinte método:

async sync({model, event, data}: {model: string, event: string, data: Category}) {
    if(model === 'category') {
      switch (event) {
        case 'created':
          await this.categoryRepo.create({
            ...data,
            createdAt: new Date(),
            updatedAt: new Date()
          });
          break;
      }
    }
  }

Quando faço a chamada dele:

this.sync({model, event, data});

O typescript me retorna o seguinte erro no this:

ESLint: Promises must be handled appropriately or explicitly marked as ignored with the void operator.(@typescript-eslint/no-floating-promises)

Como posso tratar isso?

Rafael Costa
  • 374
  • 1
  • 4
  • 14