Resolved type
TypeScript 4.5 的 Awaited 类型的较窄版本,以递归方式解包“等待的类型”,模拟 await的行为。
type Resolved<T> = (T extends { then(onfulfilled: F) => any } ? (F extends (value: V) => any ? Resolved<V> : never) : T)
你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
TypeScript 4.5 的 Awaited 类型的较窄版本,以递归方式解包“等待的类型”,模拟 await的行为。
type Resolved<T> = (T extends { then(onfulfilled: F) => any } ? (F extends (value: V) => any ? Resolved<V> : never) : T)