Leveraging TypeScript in Cross-functional development teams Aaron McGee, Richard Brookes M216
var typeScriptBoolean: boolean = true; var typeScriptNumber: number = 10; var typeScriptString: string = "Hello World"; var anyOldType: any = "what evs";
var typeScriptBoolean = true; var typeScriptNumber = 10; var typeScriptString = "Hello World"; var anyOldType = "what evs";
enum Color { Red, Green, Blue }; var c: Color = Color.Green;
var Color; (function (Color) { Color[Color["Red"] = 0] = "Red"; Color[Color["Green"] = 1] = "Green"; Color[Color["Blue"] = 2] = "Blue"; })(Color || (Color = {})); ; var c = 1 /* Green */;
var list: number[] = [1, 2, 3]; var list: Array = [1, 2, 3];
var list = [1, 2, 3];
interface ILabelledValue { label: string; } function printLabel(labelledObj: ILabelledValue) { console.log(labelledObj.label); } var myObj = { size: 10, label: "Size 10" }; printLabel(myObj);
function printLabel(labelledObj) { console.log(labelledObj.label); } var myObj = { size: 10, label: "Size 10" }; printLabel(myObj);
interface SearchFunc { (source: string, subString:string): boolean; } var mySearch: SearchFunc; mySearch = function(src: string, sub: string) { //some implementation return true; }
var mySearch; mySearch = function (src, sub) { //some implementation return true; };
interface ClockInterface { currentTime: Date; } class Clock implements ClockInterface { currentTime: Date; constructor(h: number, m: number) { } }
var Clock = (function () { function Clock(h, m) { } return Clock; })();
module Time { export interface ClockInterface { currentTime: Date; } export class Clock implements ClockInterface { currentTime: Date; constructor(h: number, m: number) { } }
var Time; (function (Time) { var Clock = (function () { function Clock(h, m) { } return Clock; })(); Time.Clock = Clock; })(Time || (Time = {}));
Contact us:
Subscribe to our fortnightly newsletter Free Online Learning Sessions on Demand