Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In my project, I was using [email protected] and it was working fine, but now I updated its version to latest [email protected] 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??

like image 685
Naila Akbar Avatar asked Dec 18 '20 10:12

Naila Akbar


People also ask

Did you forget include void?

Did you forget to include 'void' in your type argument to Promise" occurs when we use the Promise constructor without passing it an argument. To solve the error, use a generic to type the value of the Promise to void .

What means Promise void?

specifically for the case of defining a function as () => void , the function won't check the return value at all and you can return anything (even a promise). Defining a function as async will just wrap the return value in a promise, which the () => void type will just ignore.

Did you forget to include 'void' in your type argument to promise?

Did you forget to include 'void' in your type argument to Promise" occurs when we use the Promise constructor without passing it an argument. To solve the error, use a generic to type the value of the Promise to void. Here is an example of how the error occurs. Copied!

What is ts2794 and ts2345 errors?

error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'? error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'? error TS2345: Argument of type ' (value: unknown) => void' is not assignable to parameter of type ' () => void'.

What is TypeError sorted expected 1 argument got 0?

What is TypeError: sorted expected 1 argument, got 0? Computer scientist for 11+ years and passionate about math since childhood. Author has 6.1K answers and 5.7M answer views 2 y It means that you called the sorted () function without any arguments, and it expects an argument. For example (this is copy-pasted straight from an IPython session)

How do I fix expected 1 argument but got 0 error?

The error "Expected 1 argument, but got 0" occurs when we invoke a function that takes 1 parameter, without passing it any arguments. To solve the error, pass the required argument to the function, provide a default value for it or mark the parameter as optional. Here is an example of how the error occurs.


1 Answers

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())
})
like image 111
Mike S. Avatar answered Oct 19 '22 20:10

Mike S.