Jesse_Liberty_TypeScriptForCSharpDevs
Jesse_Liberty_TypeScriptForCSharpDevs
Jesse Liberty
@Jesseliberty
http://jesseliberty.com
Getting Acquainted with TypeScript
Anders Hejlsberg
• Delphi
• Turbo Pascal
• C#
• TypeScript
Key Features
Constructors,
Static Typing Classes Properties,
Methods
Arrow Functions
Interfaces Encapsulation
(Lambdas)
Key Features
Supports Standard
JavaScript code Open Source Runs Anywhere
Excellent Tool
Intellisense Syntax Checking
Support
TypeScript is TypeScript is a typed
JavaScript superset of Javascript
C#
Why use TypeScript?
TypeScript Type Safety
Setup
Tooling
Visual Studio Otherwise… Playground
It just works Any browser
Any editor
Any OS
http://typescriptlang.org
VS Code - Setup
• Download and install VS Code
(https://code.visualstudio.com/)
Interfaces
Classes
Constructors
Properties
Fields
Methods (functions)
TypeScript and Types
TypeScript and Types
• Boolean ( true or false )
• Enum ( temperature.hot )
• Array ( myArray[4] )
TypeScript and Types
• Void ( function does not return a value )
let a = 10;
a == 10 // true a == “10” // true
a === 10 // true a === “10” // false
Flow Control
• if, if…else
• ?: (ternary)
• switch
• while, while..do
• for
Flow Control – for..in
a = value1
b = value2
c = value3
Functions
Optional & Default Parameters
• Optional parameters use ?
• Demo
Default Parameters
• Somewhat cleaner than optional parameters
• Demo
Rest Parameters
• Very much like “params”
• Demo
Function Overloading
• Same name, different number of parameters
• Demo
Arrow Functions
• Lambda Expressions
• Demo
Object-oriented TypeScript
Object Literals
var rectangle = {
height: 20,
width: 10,
area: function () { return this.height * this.width;}
}
• Demo
Inheritance
• Uses the keyword extends
• Demo
Interfaces
• Uses the keyword implements
• Demo
Advanced Topics
• Modules
• Asynchronous programming
• Testing
• Stack Overflow
• Blogs (http://jesseliberty.com)
• Twitter
Questions?
Thank you
Jesse liberty
@jesseliberty
jesseliberty.com