You can either annotate the return type of the function with Promise <T> , where T is the desired type, or assign the result to a temporary local with an explicit type annotation, and then return that local one. Then the type of the returned function will be displayed.
Explicit return type annotation:
async myfunc(): Promise<{name: string}> { const response = await fetch('example.com'); return await response.json(); }
Derived a return type from an explicitly annotated local:
async myfunc() { const response = await fetch('example.com'); const result: {name: string} = await response.json(); return result; }
source share