Summary
By now, you know how to create the most important building blocks of any TypeScript program – functions. We have explored the difference between function expressions and arrow functions and when to use which. We looked at immediately invoked function expressions, closures, currying, and other powerful TypeScript techniques.
We talked about functional programming paradigms and looked at how to include functions in objects and classes. We've looked at how to convert legacy JavaScript code into modern TypeScript and how we can improve our software by doing so.
We have had an overview of the TypeScript module system and the critically important import
and export
keywords. We wrote a lot of our own TypeScript code and learned how to test it with ts-jest
.
Finally, we rounded out this chapter with a discussion of error handling. We'll look at more advanced error-handling techniques in Chapters 12, Guide to Promises in TypeScript, and Chapter 13, Async Await...