MODULARITY AND UNIT TESTING IN TYPESCRIPT Suthep Sangvirotjanaphat Founder and Instructor of GreatFriends.biz Microsoft MostValuable Professional
hi
GreatFriends ■ Page fb.com/greatfriends.biz ■ Group fb.com/groups/greatfriends.biz ■ Web next.greatfriends.biz ■ Me fb.com/suthep Other FB Groups ■ F#Thai ■ TypeScriptThailand ■ gitฮับ และ​​มือใหม่Gitฮับ ■ .NET Framework Source Code Study Group
TypeScript Features from the future, today. ■ 0.8 ■ 1.0 ■ 1.3 ■ 1.4 ■ 1.5 ■ 1.6 ■ 2.0
TYPESCRIPT TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
TypeScript
DefinitelyTyped and tsd ■ http://definitelytyped.org ■ http://definitelytyped.org/tsd
Lang. ■ Types ■ Classes ■ Interfaces ■ Generics
Type annotation var x : number; x = true; // error x = 100; // ok function print(s : string) : void { console.log(s); } print(x); // error print(x.toString()); // ok
Type inference var x = 10; // infer x as a number var x : number = 10; // infer this function return type as string function Foo(n: number) { return n.toFixed(2); } function Foo(n: number) : string { … }
Basic types boolean // var b = true, c = false; number // var n = 100, m = 10.0; string // var s = 'Hello'; array // var a1: number[] = [ 1, 3, 5 ]; array // var a2: Array<number> = [ ]; enum // var c = Color.red; any // var x; void // foo(): void { }
Class
Interface and duck typing
Arrow functions
UsingTypeScript with AngularJS
Demo 1 of 3 ■ Install typescript ■ Coding and compiling ■ Install tsd ■ Install definition files from 3rd party libraries
TypeScript 1.5 ■ Lots of ES 6 language features ■ Modules ■ Decorators
ES 6 language features ■ modules ■ destructing ■ spread ■ for..of ■ computed properties ■ let/const ■ tagged string template
Decorators ■ needs --experimentalDecorators compiler option
TypeScript Internal Modules
External Modules import and export
commonjs and amd
umd
import statement
Demo 2 of 3 ■ Kafi Project ■ Live Demo
kafi.azurewebsites.net github.com/surrealist/kafi
Kafi (class model)
UnitTesting with mocha and chai mochajs.org chaijs.com
mocha
Demo 3 of 3 ■ unit testing inTypeScript
More resources aboutTypeScript http://facebook.com/groups/typescript.thailand http://www.typescriptlang.org http://www.typescriptlang.org/Handbook http://blogs.msdn.com/b/typescript http://definitelytyped.org http://definitelytyped.org/tsd https://github.com/microsoft/typescript https://github.com/microsoft/typescript/wiki
Q&A More fun ahead! please visit and join GreatFriends! ■ Page fb.com/greatfriends.biz ■ Group fb.com/groups/greatfriends.biz ■ Web next.greatfriends.biz ■ Me fb.com/suthep

Mudularity and Unit Testing in TypeScript (for ng-bkk #3)