naskah mendapatkan tipe dari janji
function promiseOne() {
return Promise.resolve(1)
}
const promisedOne = promiseOne()
// note PromiseLike instead of Promise, this lets it work on any thenable
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T
type PromiseOneThenArg = ThenArg<typeof promisedOne> // => number
// or
type PromiseOneThenArg2 = ThenArg<ReturnType<typeof promiseOne>> // => number
Annoyed Alpaca