I have the following code. performAsyncAction
performs an async action and returns Promise<Response>
. In someFunction
, I was surprised that TypeScript doesn't warn about not using await on a function that returns a promise.
function performAsyncAction() {
return fetch('someservice');
}
function someFunction() {
const result = performAsyncAction(); // Was expecting typescript to give error here
}
I found a relevant linting rule that may help promise-function-async
It is not an error, it is intended behaviour.
async
, therefore it is not even possible to await thereawait
Promise or if you .then
Promise, its only syntactic sugar (useful one though)