Обещание является асинхронной операцией,
const p : Promise<number> =
new Promise<number>((resolve, reject)=>{
//do some operations here, and the desired output is ready, say result = 5;
resolve(result)
//or if you hit an error you can get the error obj, e and
reject(e)
});
Вы можете выполнить вызов обещания сейчас, и результат после выполнения будет доступен в .then
p()
.then((resolvedResult:number)=>console.log(resolvedResult),(rejectedError)=>console.log(rejectedError))