86

In my project, I was using Typescript@4.0.3 and it was working fine, but now I updated its version to latest Typescript@4.1.3 and it is giving me a lot of errors. I am unable to find anything in documentations and not getting any Idea how to resolve this issue.

here is my code:

dbPool.query(`DELETE FROM table WHERE Id='${Id}'`, () => resolve())

Another one is:

return new Promise((resolve, reject) => {
  this.redis.SET(addr, resp, () => resolve())
})

These both are giving me error:

error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?

Any idea what should I pass in resolve() to resolve this issue??

Naila Akbar
  • 3,033
  • 4
  • 34
  • 76
  • Why do you want to resolve your promise with `undefined`? Does `this.red.SET` have no result? – Bergi Dec 18 '20 at 10:14
  • This is an old code, and I really don't know what is happening in there. I just made a little change and due to typescript version conflict, now I am unable to make a build. – Naila Akbar Dec 18 '20 at 10:17
  • sorry a typo here, that was not red, it is redis – Naila Akbar Dec 18 '20 at 10:22

1 Answers1

197

The standard argument for resolve in your case is unknown, which means that an argument is required;

If you don't want resolve to be taking any arguments you can explicitly set the generic type of Promise to void;

return new Promise<void>((resolve, reject) => {
  this.red.SET(addr, resp, () => resolve())
})
Jeff Schaller
  • 2,352
  • 5
  • 23
  • 38