Promises and async/await notation

Promises are ECMAScript 2015's way of handling asynchronous operations. They have extensive support across all mainstream browsers, with the exception of Internet Explorer. In any case, polyfills are available. With an ES5 target, the use of promises in TypeScript requires the addition of the "es2015.promise" and "es2018.promise" declaration libraries to the "lib" compiler option:

"lib": ["dom", "es5",         "es2015.symbol","es2015.symbol.wellknown",         "es2015.generator","es2015.iterable",         "dom.iterable", "es2015.collection",         "es2015.promise", "es2018.promise"        ]

With the Promise pattern, functions that execute asynchronous operations, instead of accepting a callback that is invoked when the asynchronous operation ...

Get Hands-On TypeScript for C# and .NET Core Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.