📜  打字稿从承诺中获取类型 - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:13.433000             🧑  作者: 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