📜  typescript 获取 promise 返回类型 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:13.039000             🧑  作者: Mango

代码示例2
function promiseOne() {
  return Promise.resolve(1)
}
    
const promisedOne = promiseOne()
    
// note PromiseLike instead of Promise, this lets it work on any thenable
type ThenArg = T extends PromiseLike ? U : T
    
type PromiseOneThenArg = ThenArg // => number
// or
type PromiseOneThenArg2 = ThenArg> // => number