TypeScript 101. TypeScript is a tool that allows you to utilize object oriented programming techniques with your JavaScript code. With TypeScript you have the same sort of namespaces and classes that you use to build your business objects. TypeScript classes support both inheritance and interfaces. We’ll introduce you to these concepts and show you how to use TypeScript to manage and organize your JavaScript code.
2. What is TypeScript
TypeScript is a superset of JavaScript
You can enter pure JavaScript into TypeScript
TypeScript gives you type safety.
TypeScript gives you encapsulation.
TypeScript allows you to organize your code into Modules and Classes
4. TypeScript Features
• Standard JavaScript Code
• Static Typing
• Encapsulation with Modules and Classes
• Classes support Constructors, Properties,
Fields and Functions
• Interfaces
• Lambda Functions =>
• Intellisense and syntax checking
5. Additional Keywords and Operators
exports and imports
constructor
extends
implements
Interface
public/private
… Rest syntax
=> Arrow or lambda functions
<typename> type conversion
: assignment
6. Code Hierarchy
Module
Interface Class
Fields
Constructors
Properties
Functions
9. Classes
Class Members – Fields, Properties, Functions, Constructors
Add functions to a class. Note lack of function keyword
Define properties
Complex Types (object types) – Instantiate with New keyword
Types can be cast
https://github.com/borisyankov/DefinetlyTyped
Extending Types – super() function. Similar to base
Immediately-invoked function expression – iffy
11. Modules
Benefits – Separation of concern, maintainable, testable, reusable
Open – Can be exposed for both Import and Export
Asynchronous Module Definition - AMD