0
const _create = async ({ email, pass }) => {
  try {
    const saltRounds = 10;
    const salt = await bcrypt.genSalt(saltRounds);
    const hashed = await bcrypt.hash(pass, salt);
    ....

I have 2 files with similar code like above, one is working fine but other is giving warning 'await' has no effect on the type of this expression

hash is returning a promise still the warning. enter image description here

enter image description here

  • 1
    What in particular is "giving warning" here? – AKX Apr 22 '22 at 07:26
  • @AKX await on line 9 is showing given warning. I have edited the same. – Nishant Chorge Apr 22 '22 at 07:33
  • Those functions don't return promises; see the docs how async is supposed to work: https://www.npmjs.com/package/bcryptjs#usage---async – deceze Apr 22 '22 at 07:38
  • @deceze if callback is not provided it does returns a promise, you can check the documentation. for synchronous there is a different function hashSync. – Nishant Chorge Apr 22 '22 at 07:59
  • Hmm, true. Then the issue is that your IDE doesn't detect this properly either and issues this superfluous warning. – deceze Apr 22 '22 at 08:01
  • I got why the warning is thrown. It is only showing if i am having default parameters. In my function pass is default parameter – Nishant Chorge Apr 22 '22 at 08:01

0 Answers0