ReturnType<T> lấy return type của function T mà không cần khai báo lại: type Result = ReturnType<typeof fetchUser> tự động theo dõi khi hàm thay đổi. Awaited<T> unwrap Promise đệ quy: Awaited<Promise<string>> cho ra string, Awaited<Promise<Promise<number>>> cho ra number.
- Kết hợp cả hai cho async functions:
type Data = Awaited<ReturnType<typeof fetchData>>. - Rất hữu ích trong large codebases để tránh type duplication và đảm bảo types luôn đồng bộ với implementation.