I'm going to put a barebones example here of what I think should work, but doesn't.
const getData = async () => {
const data = await makeAnAsyncCall() //returns a promise of SomeType
return data
}
const actuallyUseTheData = () => {
const data: SomeType = getData()
//more code...
}
This invariably leads to the error:
Variable of type Promise<SomeType> cannot be assigned to SomeType. Did you forget to use 'await'?
But I'm getting the data in an async function which uses await!
getData(). (Which meansactuallyUseTheDatawould also need to beasync, unless you want/need to use callbacks therein for some other reason.)async(orPromises, etc) is contagious" is the issue.awaitdoesn't turn asynchronous code into synchronous code, it just turns asynchronous code into code that looks synchronous. You can't synchronously call an async function and get the answer "right away".