TypeScript does not provide new functionality to JavaScript, it "merely" introduces typing. As such, you'll need to look at how different JavaScript libraries handle async requests,choose your likings and reference the corresponding definition file.
For the first part, I'm going to assume you are using jQuery
(as your question is tagged likewise). In jQuery, async requests are handled by promises. I suggest reading the docs and looking online for other tutorials on how to use them. I will provide a TypeScript example below.
After you've chosen which JavaScript library to use, you'll need a TypeScript definition file (*.d.ts
). Basically this is equivalent to a C header file. A definition file will tell the TypeScript compiler there exist scopes, variables and methods without having to provide a TypeScript implementation. In case of the jQuery defintion file, it will tell the compiler there's a scope named $
as well as all variables and methods defined on that scope. A socially maintained repository of defintion files can be found here. It also includes documentation on how to reference the files in your project.
Lastly, you'll need to make use of promises in your TypeScript code, example code below.
$.post("http://www.hateverurl.dom", options).done(() => {
// the POST request has finished succesfully when this method is invoked.
})