I've defined the following JavaScript function
async isDataValid (externalValidation = true) {
const isValid = (await this.v$.$validate()) && externalValidation
// other stuff not relevant to my question happens here
return isValid
}
AFAIK, I need to define this as an async
function in order to await the result of this.v$.$validate()
.
Because isDataValid
is itself async
, I thought I need to use await
whenever I call it, but when I did the following:
const result = await this.isDataValid()
My IDE marked this with a warning
Redundant 'await' for a non-promise type
So it seems my IDE is saying that await
only needs to be used if an async
function returns a promise i.e. there is no need to use await
with isDataValid
because it returns a boolean.
Does await
need to be used when calling all async
functions, or only those that return a promise?
Update
I am using JavaScript, not TypeScript