TypeScript 101



Ross Terman
www.xeq.com
rterman@xeq.comt
ed by Ross Terman
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
Get TypeScript
www.TypeScriptLang.org
http://www.typescriptlang.org/Content/TypeScript
%20Language%20Specification.pdf
Web Essentials
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
Additional Keywords and Operators
 exports and imports
constructor
extends
implements
Interface
public/private
… Rest syntax
=> Arrow or lambda functions
<typename> type conversion
: assignment
Code Hierarchy
                  Module



    Interface      Class



                   Fields
                Constructors
                 Properties
                 Functions
Types
Type Inference
Annotations
Type Definition Files
Primitive Types: Number, String, Boolean, Any, Null, Undefined
Object Types
Functions
Parameters – Required and Optional


Arrow (lambda) functions


Void for functions that return no value
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
Interfaces
Optional members
Implementing
Using an Interface as a type
Extend interface
Modules
Benefits – Separation of concern, maintainable, testable, reusable
Open – Can be exposed for both Import and Export
Asynchronous Module Definition - AMD
Resources

http://www/typescriptlang.org
http://www.typescriptlang.org/Content/TypeScript%20Language%20Specifica
tion.pdf
http://www.johnpapa.net/
http://weblogs.asp.net/dwahlin/
http://pluralsight.com/training/
Contact Us
Ross Terman – 305-726-6925
rterman@xeq.com
@xeqinfo

TypeScript 101