type AsyncReturnType Promise> = T extends (...args: any) => Promise ? R : never; async function fetchUserData(id: string) { const response = await fetch(`/api/users/${id}`); const data: { id: string; name: string; email: string } = await response.json(); return data; } async function processData(input: number): Promise { return Promise.resolve(input.toString()); } // Example Usage: type UserDataType = AsyncReturnType; // UserDataType will be: { id: string; name: string; email: string } type ProcessResultType = AsyncReturnType; // ProcessResultType will be: string // Type 'UserDataType' is assignable to variable 'user' const user: UserDataType = { id: "user-123", name: "Alice", email: "alice@example.com" }; // Type 'ProcessResultType' is assignable to variable 'result' const result: ProcessResultType = "42"; // Function returning non-Promise is not assignable // function syncFunc(): string { return 'hello'; } // type SyncResult = AsyncReturnType; // Error: Type 'typeof syncFunc' does not satisfy the constraint '(...args: any) => Promise'.