├── 14_module_demo ├── .tscache │ └── default │ │ ├── timestamp │ │ └── hashes │ │ ├── app.ts-f98485da1849ae631ba5c04e5cec07dd │ │ ├── cart.component.ts-dad66dad18660f8b81b9a84cad864b7b │ │ ├── products.service.ts-564e8cd68a23da2f32a09091eb8231ff │ │ └── utility.component.ts-d3d8d90f646fa0c56ec283b2d6202187 ├── public │ ├── media │ │ ├── css │ │ │ └── style.css │ │ ├── js │ │ │ └── script.js │ │ └── images │ │ │ └── image.png │ └── index.html ├── bin │ ├── public │ │ ├── media │ │ │ ├── css │ │ │ │ └── style.css │ │ │ ├── images │ │ │ │ └── image.png │ │ │ └── js │ │ │ │ └── script.js │ │ └── index.html │ ├── service │ │ ├── products.service.js.map │ │ └── products.service.js │ ├── component │ │ ├── cart.component.js.map │ │ ├── cart.component.js │ │ ├── utility.component.js.map │ │ └── utility.component.js │ ├── app.js.map │ └── app.js ├── tslint.json ├── src │ ├── component │ │ ├── cart.component.ts │ │ └── utility.component.ts │ ├── service │ │ └── products.service.ts │ └── app.ts ├── tsconfig.json ├── package.json ├── Gruntfile.js └── .gitignore ├── FirstProject ├── src │ └── index.ts ├── dist │ ├── index.js.map │ └── index.js ├── tslint.json ├── package.json ├── tsconfig.json ├── README.md └── package-lock.json ├── 04_08_DataType_Void.ts ├── README.md ├── 04_07_DataType_Any.ts ├── 01_FirstProgram.ts ├── 05_01_TypeAssertion.ts ├── 12_01_Static.ts ├── 07_03_Function_Overloading.ts ├── 07_04_Function_RestParameters.ts ├── 02_TypeAnnotation.ts ├── 04_06_DataType_Union.ts ├── 13_01_Generics.ts ├── 07_02_Function_ArrowFunction.ts ├── 10_01_AbtractClass.ts ├── 04_04_DataType_Tuple.ts ├── 04_05_DataType_Enum.ts ├── 04_01_DataType_Number.ts ├── 04_03_DataType_Array.ts ├── 07_01_Function.ts ├── 09_01_Interface.ts ├── 11_01_DataModifiers.ts ├── 06_01_Constructs.ts ├── 08_01_Class.ts ├── 03_Variable.ts ├── 04_02_DataType_String.ts └── .gitignore /14_module_demo/.tscache/default/timestamp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/public/media/css/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/public/media/js/script.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/bin/public/media/css/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/bin/public/media/images/image.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/bin/public/media/js/script.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /14_module_demo/public/media/images/image.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /FirstProject/src/index.ts: -------------------------------------------------------------------------------- 1 | export let hello = () => { 2 | return 'Hello World!'; 3 | } -------------------------------------------------------------------------------- /14_module_demo/.tscache/default/hashes/app.ts-f98485da1849ae631ba5c04e5cec07dd: -------------------------------------------------------------------------------- 1 | d1b5759e7ec1abb32a440fa20ad0ec27 -------------------------------------------------------------------------------- /14_module_demo/.tscache/default/hashes/cart.component.ts-dad66dad18660f8b81b9a84cad864b7b: -------------------------------------------------------------------------------- 1 | 75a0b4089ce0937803cc69d907636602 -------------------------------------------------------------------------------- /14_module_demo/.tscache/default/hashes/products.service.ts-564e8cd68a23da2f32a09091eb8231ff: -------------------------------------------------------------------------------- 1 | 27c3fec34d8dcefb1a7179c85ad14b6c -------------------------------------------------------------------------------- /14_module_demo/.tscache/default/hashes/utility.component.ts-d3d8d90f646fa0c56ec283b2d6202187: -------------------------------------------------------------------------------- 1 | 03e08cd4979912942cee3b0dea6eaaf0 -------------------------------------------------------------------------------- /FirstProject/dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAW,QAAA,KAAK,GAAG;IACf,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAA"} -------------------------------------------------------------------------------- /04_08_DataType_Void.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Data Type - Void 2 | 3 | function sayHi(): void { 4 | console.log('Hi!') 5 | } 6 | 7 | let speech: void = sayHi(); 8 | console.log(speech); //Output: undefined -------------------------------------------------------------------------------- /FirstProject/dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.hello = function () { 4 | return 'Hello World!'; 5 | }; 6 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /14_module_demo/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": "tslint-config-airbnb", 4 | "jsRules": {}, 5 | "rules": { 6 | "eofline": false 7 | }, 8 | "rulesDirectory": [] 9 | } -------------------------------------------------------------------------------- /FirstProject/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": "tslint-config-airbnb", 4 | "jsRules": {}, 5 | "rules": { 6 | "eofline": false 7 | }, 8 | "rulesDirectory": [] 9 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Visual Studio Code Extensions 2 | Javascript (ES6) code snippets 3 | Live Sass Compiler 4 | Live Server 5 | Material Icon Theme 6 | npm 7 | Path Intellisense 8 | Prettier - Code Formatter 9 | Project Manager 10 | Quokka -------------------------------------------------------------------------------- /14_module_demo/src/component/cart.component.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import * as products from '../service/products.service'; 3 | import { ProductsService } from '../service/products.service'; 4 | 5 | let s = new ProductsService(); -------------------------------------------------------------------------------- /04_07_DataType_Any.ts: -------------------------------------------------------------------------------- 1 | // Example: Any 2 | let something: any = "Hello World!"; 3 | something = 23; 4 | something = true; 5 | 6 | // Example: Any type Array 7 | let arr: any[] = ["John", 212, true]; 8 | arr.push("smith"); 9 | console.log(arr); //Output: [ 'John', 212, true, 'Ram' ] -------------------------------------------------------------------------------- /01_FirstProgram.ts: -------------------------------------------------------------------------------- 1 | // Installation 2 | // npm install typescript -g 3 | 4 | // First Program 5 | // add.ts 6 | function addNumbers(a: number, b: number) { 7 | return a + b; 8 | } 9 | var sum: number = addNumbers(10,15); 10 | console.log('Sum of the two numbers is: ' +sum); -------------------------------------------------------------------------------- /14_module_demo/bin/service/products.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"products.service.js","sourceRoot":"","sources":["../../src/service/products.service.ts"],"names":[],"mappings":";;AAAA,MAAa,eAAe;CAE3B;AAFD,0CAEC;AAOD,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC"} -------------------------------------------------------------------------------- /14_module_demo/bin/component/cart.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"cart.component.js","sourceRoot":"","sources":["../../src/component/cart.component.ts"],"names":[],"mappings":";;AAEA,kEAA8D;AAE9D,IAAI,CAAC,GAAG,IAAI,kCAAe,EAAE,CAAC;AAC9B,aAAa,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /14_module_demo/bin/service/products.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | class ProductsService { 4 | } 5 | exports.ProductsService = ProductsService; 6 | function logDebug(message) { 7 | console.log(message); 8 | } 9 | //# sourceMappingURL=products.service.js.map -------------------------------------------------------------------------------- /05_01_TypeAssertion.ts: -------------------------------------------------------------------------------- 1 | // Type assertion allows you to set the type of a value and tell the compiler not to infer it. 2 | let myCode: any = 123; 3 | let employeeCode = myCode; 4 | console.log(typeof(employeeCode)); //Output: number 5 | 6 | // Using as keyword 7 | let thisCode: any = 123; 8 | let thatCode = thisCode as number; -------------------------------------------------------------------------------- /14_module_demo/bin/component/cart.component.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const products_service_1 = require("../service/products.service"); 4 | let s = new products_service_1.ProductsService(); 5 | StringUtility.subString('abc', 1, 2); 6 | //# sourceMappingURL=cart.component.js.map -------------------------------------------------------------------------------- /14_module_demo/src/service/products.service.ts: -------------------------------------------------------------------------------- 1 | export class ProductsService { 2 | // .. Service code here 3 | } 4 | 5 | interface Product { 6 | // Interface declarations 7 | } 8 | 9 | // Private function to this module, not on the global namespace 10 | function logDebug(message: string) { 11 | console.log(message); 12 | } 13 | 14 | // Export as a single statement 15 | export { Product }; 16 | -------------------------------------------------------------------------------- /12_01_Static.ts: -------------------------------------------------------------------------------- 1 | // The static members of a class are accessed using the class name and dot notation, without creating an object e.g. .. 2 | 3 | //Example: Static Members 4 | class Circle { 5 | static pi: number = 3.14; 6 | 7 | static calculateArea(radius:number) { 8 | return this.pi * radius * radius; 9 | } 10 | } 11 | Circle.pi; // returns 3.14 12 | Circle.calculateArea(5); // returns 78.5 13 | -------------------------------------------------------------------------------- /14_module_demo/src/component/utility.component.ts: -------------------------------------------------------------------------------- 1 | namespace StringUtility { 2 | export function toCapital(str: string): string { 3 | return str.toUpperCase(); 4 | } 5 | 6 | export function subString(str: string, from: number, length: number = 0): string { 7 | return str.substr(from, length); 8 | } 9 | } 10 | 11 | namespace Calculator { 12 | export function add(num1: number, num2: number): number { 13 | return num1 + num2; 14 | } 15 | } -------------------------------------------------------------------------------- /07_03_Function_Overloading.ts: -------------------------------------------------------------------------------- 1 | // TypeScript - Function Overloading 2 | // Multiple functions with the same name but different parameter types and return type. 3 | // However, the number of parameters should be the same. 4 | 5 | //Example: Function Overloading 6 | function add(a:string, b:string):string; 7 | 8 | function add(a:number, b:number): number; 9 | 10 | function add(a: any, b:any): any { 11 | return a + b; 12 | } 13 | 14 | add("Hello ", "Steve"); // returns "Hello Steve" 15 | add(10, 20); // returns 30 -------------------------------------------------------------------------------- /07_04_Function_RestParameters.ts: -------------------------------------------------------------------------------- 1 | // Pass zero or more arguments to the rest parameter. 2 | // The compiler will create an array of arguments with the provided rest parameter name. 3 | 4 | // Example: Rest Parameters 5 | function greetSomeone(greeting: string, ...names: string[]) { //rest parameters must come last in the function defination 6 | return greeting + " " + names.join(", ") + "!"; 7 | } 8 | 9 | greetSomeone("Hello", "Steve", "Bill"); // returns "Hello Steve, Bill!" 10 | 11 | greetSomeone("Hello");// returns "Hello !" -------------------------------------------------------------------------------- /14_module_demo/src/app.ts: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import cors from 'cors'; 3 | import fp from 'path'; 4 | 5 | // user-defined function 6 | // __dirname is a constant variable 7 | function relative(path: string) { 8 | return fp.join(__dirname, path); 9 | } 10 | 11 | const app = express(); 12 | 13 | app.use(cors()); 14 | app.use(express.json()); 15 | app.use(express.urlencoded({ extended: false })); 16 | app.use(express.static(relative('public'))); 17 | console.log(process.env.NODE_ENV); 18 | app.listen(8000, () => { 19 | console.log(`Running application!`); 20 | }); -------------------------------------------------------------------------------- /FirstProject/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FirstProject", 3 | "version": "1.0.0", 4 | "description": "-- Install Typescript $ npm i typescript -g -- Setup $ tsc --init -- Compilation $ tsc -- Compilation with Watch $ tsc -w", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "tslint": "^5.18.0", 14 | "typescript": "^3.5.2" 15 | }, 16 | "dependencies": { 17 | "tslint-config-airbnb": "^5.11.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /14_module_demo/bin/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

Awesome Web Project!


17 |

local

18 | 19 | -------------------------------------------------------------------------------- /14_module_demo/bin/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,gDAAwB;AACxB,gDAAsB;AAItB,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,cAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,GAAG,GAAG,iBAAO,EAAE,CAAC;AAEtB,GAAG,CAAC,GAAG,CAAC,cAAI,EAAE,CAAC,CAAC;AAChB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACxB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACjD,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC5C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAClC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IAClB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /02_TypeAnnotation.ts: -------------------------------------------------------------------------------- 1 | // start: Type Annotations 2 | // - Javascript is not typed language vs Typescript is a typed language 3 | var age: number = 32; // number variable 4 | var customerName: string = "John";// string variable 5 | var isUpdated: boolean = true;// Boolean variable 6 | 7 | // Type Annotation of Parameters 8 | function display(id:number, name:string) { 9 | console.log("Id = " + id + ", Name = " + name); 10 | } 11 | 12 | // Type Annotation in Object 13 | var employee : { 14 | id: number; 15 | name: string; 16 | }; 17 | 18 | // If you try to assign a string value to id then the TypeScript compiler will give the following error. 19 | employee = { 20 | id: 100, 21 | name : "John" 22 | } 23 | console.log(employee); 24 | 25 | // end: Type Annotations -------------------------------------------------------------------------------- /14_module_demo/bin/component/utility.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utility.component.js","sourceRoot":"","sources":["../../src/component/utility.component.ts"],"names":[],"mappings":";AAAA,IAAU,aAAa,CAQtB;AARD,WAAU,aAAa;IACnB,SAAgB,SAAS,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAFe,uBAAS,YAExB,CAAA;IAED,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAY,EAAE,SAAiB,CAAC;QACnE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAFe,uBAAS,YAExB,CAAA;AACL,CAAC,EARS,aAAa,KAAb,aAAa,QAQtB;AAED,IAAU,cAAc,CAQvB;AARD,WAAU,cAAc;IACpB,SAAgB,SAAS,CAAC,GAAW;QACjC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAFe,wBAAS,YAExB,CAAA;IAED,SAAgB,SAAS,CAAC,GAAW,EAAE,IAAY,EAAE,SAAiB,CAAC;QACnE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAFe,wBAAS,YAExB,CAAA;AACL,CAAC,EARS,cAAc,KAAd,cAAc,QAQvB"} -------------------------------------------------------------------------------- /14_module_demo/bin/component/utility.component.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var StringUtility; 3 | (function (StringUtility) { 4 | function toCapital(str) { 5 | return str.toUpperCase(); 6 | } 7 | StringUtility.toCapital = toCapital; 8 | function subString(str, from, length = 0) { 9 | return str.substr(from, length); 10 | } 11 | StringUtility.subString = subString; 12 | })(StringUtility || (StringUtility = {})); 13 | var StringUtility1; 14 | (function (StringUtility1) { 15 | function toCapital(str) { 16 | return str.toUpperCase(); 17 | } 18 | StringUtility1.toCapital = toCapital; 19 | function subString(str, from, length = 0) { 20 | return str.substr(from, length); 21 | } 22 | StringUtility1.subString = subString; 23 | })(StringUtility1 || (StringUtility1 = {})); 24 | //# sourceMappingURL=utility.component.js.map -------------------------------------------------------------------------------- /14_module_demo/bin/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const express_1 = __importDefault(require("express")); 7 | const cors_1 = __importDefault(require("cors")); 8 | const path_1 = __importDefault(require("path")); 9 | function relative(path) { 10 | return path_1.default.join(__dirname, path); 11 | } 12 | const app = express_1.default(); 13 | app.use(cors_1.default()); 14 | app.use(express_1.default.json()); 15 | app.use(express_1.default.urlencoded({ extended: false })); 16 | app.use(express_1.default.static(relative('public'))); 17 | console.log(process.env.NODE_ENV); 18 | app.listen(8000, () => { 19 | console.log(`Running application!`); 20 | }); 21 | //# sourceMappingURL=app.js.map -------------------------------------------------------------------------------- /04_06_DataType_Union.ts: -------------------------------------------------------------------------------- 1 | // Union allows the use more than one data type for a variable or a function parameter 2 | 3 | // Example: Union 4 | let code: (string | number); 5 | code = 123; // OK 6 | code = "ABC"; // OK 7 | code = false; // Compiler Error 8 | 9 | let employeeId: string | number; 10 | employeeId = 111; // OK 11 | employeeId = "E111"; // OK 12 | employeeId = true; // Compiler Error 13 | 14 | // Example: Function Parameter as Union Type 15 | function displayType(code: (string | number)) 16 | { 17 | if(typeof(code) === "number") 18 | console.log('Code is number.') 19 | else if(typeof(code) === "string") 20 | console.log('Code is string.') 21 | } 22 | 23 | displayType(123); // Output: Code is number. 24 | displayType("ABC"); // Output: Code is string. 25 | displayType(true); //Compiler Error: Argument of type 'true' is not assignable to a parameter of type string | number 26 | -------------------------------------------------------------------------------- /14_module_demo/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Awesome Web Project!


23 |

24 | 25 | -------------------------------------------------------------------------------- /13_01_Generics.ts: -------------------------------------------------------------------------------- 1 | /* 2 | function getArray(items : any[] ) : any[] { 3 | return new Array().concat(items); 4 | } 5 | 6 | let myNumArr = getArray([100, 200, 300]); 7 | let myStrArr = getArray(["Hello", "World"]); 8 | 9 | myNumArr.push(400); // OK 10 | myStrArr.push("Hello TypeScript"); // OK 11 | 12 | myNumArr.push("Hi"); // OK 13 | myStrArr.push(500); // OK 14 | 15 | console.log(myNumArr); // [100, 200, 300, 400, "Hi"] 16 | console.log(myStrArr); // ["Hello", "World", "Hello TypeScript", 500] 17 | */ 18 | 19 | // Example: Generic Function 20 | function getArray(items : T[] ) : T[] { 21 | return new Array().concat(items); 22 | } 23 | 24 | let myNumArr = getArray([100, 200, 300]); 25 | let myStrArr = getArray(["Hello", "World"]); 26 | 27 | myNumArr.push(400); // OK 28 | myStrArr.push("Hello TypeScript"); // OK 29 | 30 | myNumArr.push("Hi"); // Compiler Error 31 | myStrArr.push(500); // Compiler Error -------------------------------------------------------------------------------- /07_02_Function_ArrowFunction.ts: -------------------------------------------------------------------------------- 1 | // TypeScript - Arrow Function 2 | // Fat arrow notations are used for anonymous functions i.e for function expressions. 3 | // They are also called lambda functions in other languages. 4 | 5 | // Example: Parameterless Arrow Function 6 | let printer = () => console.log("Hello TypeScript"); 7 | printer(); //Output: Hello TypeScript 8 | 9 | let calculateForSum = (x: number, y: number): number => { 10 | return x + y; 11 | } 12 | 13 | calculateForSum(10, 20); //returns 30 14 | 15 | // Example: Arrow Function in Class 16 | class Person { 17 | firstName: string; 18 | lastName: string; 19 | 20 | constructor(firstName: string, lastName: string) { 21 | this.firstName = firstName; 22 | this.lastName = lastName; 23 | } 24 | 25 | display = () => console.log(this.firstName +' ' + this.lastName) 26 | } 27 | let p = new Person('John', 'Doe'); 28 | p.display(); -------------------------------------------------------------------------------- /10_01_AbtractClass.ts: -------------------------------------------------------------------------------- 1 | // Abstract classes are mainly for inheritance where other classes may derive from them. 2 | // We cannot create an instance of an abstract class. 3 | 4 | abstract class UniquePerson { 5 | name: string; 6 | 7 | constructor(name: string) { 8 | this.name = name; 9 | } 10 | 11 | display(): void { 12 | console.log(this.name); 13 | } 14 | 15 | abstract find(string): Person; 16 | } 17 | 18 | class UniqueEmployee extends UniquePerson { 19 | empCode: number; 20 | 21 | constructor(name: string, code: number) { 22 | // The class which implements an abstract class must call super() in the constructor. 23 | super(name); // must call super() 24 | this.empCode = code; 25 | } 26 | 27 | find(name: string): UniquePerson { 28 | // execute AJAX request to find an employee from a db 29 | return new UniqueEmployee(name, 1); 30 | } 31 | } 32 | 33 | let uniqueEmp: UniquePerson = new UniqueEmployee("James", 100); 34 | uniqueEmp.display(); //James 35 | -------------------------------------------------------------------------------- /FirstProject/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "sourceMap": true, /* Generates corresponding '.map' file. */ 6 | "outDir": "./dist", /* Redirect output structure to the directory. */ 7 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 8 | "strict": true, /* Enable all strict type-checking options. */ 9 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /04_04_DataType_Tuple.ts: -------------------------------------------------------------------------------- 1 | // Tuple is a new data type which includes two set of values of different data types. 2 | 3 | // Example: Tuple vs Other Data Types 4 | var empId: number = 1; 5 | var empName: string = "Steve"; 6 | 7 | // Tuple type variable 8 | var employee: [number, string] = [1, "Steve"]; 9 | var person: [number, string, boolean] = [1, "Steve", true]; 10 | 11 | var user: [number, string, boolean, number, string];// declare tuple variable 12 | user = [1, "Steve", true, 20, "Admin"];// initialize tuple variable 13 | 14 | // Example: Tuple Array 15 | var employees: [number, string][]; 16 | employees = [[1, "Steve"], [2, "Bill"], [3, "Jeff"]]; 17 | 18 | // Accessing Tuple Elements 19 | employee[0]; // returns 1 20 | employee[1]; // returns "Steve" 21 | // Add Elements into Tuple 22 | var employeeTuple: [number, string] = [1, "Steve"]; 23 | employeeTuple.push(2, "Bill"); 24 | console.log(employeeTuple); //Output: [1, 'Steve', 2, 'Bill'] 25 | 26 | employeeTuple.push(true); // Argument of type 'true' is not assignable to parameter of type 'number | string'. -------------------------------------------------------------------------------- /FirstProject/README.md: -------------------------------------------------------------------------------- 1 | # Step 1 – Add Node.js Yum Repository 2 | ``` 3 | yum install -y gcc-c++ make 4 | curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash - 5 | ``` 6 | 7 | # Step 2 – Install Node.js 8 | ``` 9 | sudo yum install nodejs 10 | ``` 11 | 12 | # Step 3 - Install Yarn using NPM (Optional) 13 | ``` 14 | sudo npm install yarn -g 15 | ``` 16 | or 17 | ``` 18 | curl -o- -L https://yarnpkg.com/install.sh | bash 19 | curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo 20 | sudo yum install yarn 21 | ``` 22 | 23 | # Step 4 - Check Node.js and NPM Version 24 | ``` 25 | node -v 26 | npm -v 27 | ``` 28 | 29 | ## Install Typescript 30 | ``` 31 | $ npm i typescript -g 32 | ``` 33 | ## Setup 34 | ``` 35 | $ tsc --init 36 | ``` 37 | ## Compilation 38 | ``` 39 | $ tsc 40 | ``` 41 | ## Compilation with Watch 42 | ``` 43 | $ tsc -w 44 | ``` 45 | 46 | ## Lint 47 | ``` 48 | npm i tslint --g or 49 | npm i tslint --save-dev 50 | tslint --init 51 | npm install tslint-config-airbnb 52 | 53 | { 54 | "defaultSeverity": "error", 55 | "extends": [ 56 | "tslint:recommended" 57 | ], 58 | "jsRules": {}, 59 | "rules": {}, 60 | "rulesDirectory": [] 61 | } 62 | ``` 63 | 64 | 65 | ## Using GTS 66 | ``` 67 | npm i gts -g 68 | gts init -y 69 | ``` 70 | -------------------------------------------------------------------------------- /04_05_DataType_Enum.ts: -------------------------------------------------------------------------------- 1 | // Enums or enumerations are a new data type supported in TypeScript. 2 | // - There are three types of enums: 3 | // - Numeric enum 4 | // - String enum 5 | // - Heterogeneous enum 6 | 7 | 8 | // 1 Numeric enums are number-based enums i.e. they store string values as numbers. 9 | // Example: Numeric Enum 10 | enum PrintMedia { 11 | Newspaper, // 0 12 | Newsletter, // 1 13 | Magazine, // 2 14 | Book // 3 15 | }; 16 | 17 | //Example: Enum as Return Type 18 | enum PrintMedia2 { 19 | Newspaper = 1, 20 | Newsletter, 21 | Magazine, 22 | Book 23 | } 24 | 25 | function getMedia(mediaName: string): PrintMedia2 { 26 | if ( mediaName === 'Forbes' || mediaName === 'Outlook') { 27 | return PrintMedia2.Magazine; 28 | } 29 | }; 30 | 31 | let mediaType: PrintMedia2 = getMedia('Forbes'); // returns Magazine 32 | 33 | // Example: String Enum 34 | enum PrintMedia3 { 35 | Newspaper = "NEWSPAPER", 36 | Newsletter = "NEWSLETTER", 37 | Magazine = "MAGAZINE", 38 | Book = "BOOK" 39 | } 40 | // Access String Enum 41 | PrintMedia3.Newspaper; //returns NEWSPAPER 42 | PrintMedia3['Magazine'];//returns MAGAZINE 43 | 44 | // Example: Heterogeneous Enum 45 | enum Status { 46 | Active = 'ACTIVE', 47 | Deactivate = 1, 48 | Pending 49 | } -------------------------------------------------------------------------------- /14_module_demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ 4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ 5 | "sourceMap": true, /* Generates corresponding '.map' file. */ 6 | "outDir": "./bin", /* Redirect output structure to the directory. */ 7 | // "outFile": './dist/index.js', 8 | "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ 9 | "strict": true, /* Enable all strict type-checking options. */ 10 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ 11 | "allowSyntheticDefaultImports": true, 12 | "baseUrl": ".", 13 | "paths": { 14 | "*": [ 15 | "node_modules/*", 16 | "src/types/*" 17 | ] 18 | } 19 | }, 20 | "include": [ 21 | "src/**/*" 22 | ], 23 | "exclude": [ 24 | "node_modules", 25 | "**/*.spec.ts" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /04_01_DataType_Number.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | // TypeScript Data Type - Number 5 | // Example: TypeScript Number Type Variables 6 | let first:number = 123; // number 7 | let second: number = 0x37CF; // hexadecimal 8 | let third:number=0o377 ; // octal 9 | let fourth: number = 0b111001;// binary 10 | 11 | console.log(first); // 123 12 | console.log(second); // 14287 13 | console.log(third); // 255 14 | console.log(fourth); // 57 15 | 16 | // Example: toFixed() 17 | let myNumber: number = 10.8788; 18 | 19 | myNumber.toFixed(); // returns 11 20 | myNumber.toFixed(1); //returns 10.9 21 | myNumber.toFixed(2); //returns 10.88 22 | myNumber.toFixed(3); //returns 10.879 23 | myNumber.toFixed(4); //returns 10.8788 24 | 25 | // Example: toLocaleString() 26 | let myNumber: number = 10667.987; 27 | 28 | myNumber.toLocaleString(); // returns 10,667.987 - US English 29 | myNumber.toLocaleString('de-DE'); // returns 10.667,987 - German 30 | myNumber.toLocaleString('ar-EG'); // returns 10667.987 in Arebic 31 | 32 | //Example: toString() 33 | let myNumber: number = 123; 34 | myNumber.toString(); // returns '123' 35 | 36 | // Example: valueOf() 37 | let myNumber = new Number(123); 38 | console.log(myNumber) //Output: a number object with value 123 39 | console.log(myNumber.valueOf()) //Output: 123 40 | console.log(typeof num) //Output: object 41 | 42 | let num2 = num.valueOf() 43 | console.log(num2) //Output: 123 44 | console.log(typeof num2) //Output: number -------------------------------------------------------------------------------- /14_module_demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "baseline_app", 3 | "version": "1.0.0", 4 | "description": "baseline_app", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Vener Guevarra", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/body-parser": "^1.17.0", 13 | "@types/cookie-parser": "^1.4.1", 14 | "@types/cors": "^2.8.5", 15 | "@types/express": "^4.17.0", 16 | "@types/node": "^12.0.10", 17 | "grunt": "^1.0.4", 18 | "grunt-bumpup": "^0.6.3", 19 | "grunt-cli": "^1.3.2", 20 | "grunt-contrib-clean": "^2.0.0", 21 | "grunt-contrib-copy": "^1.0.0", 22 | "grunt-contrib-watch": "^1.1.0", 23 | "grunt-env": "^0.4.4", 24 | "grunt-express": "^1.4.1", 25 | "grunt-express-server": "^0.5.4", 26 | "grunt-open": "^0.2.4", 27 | "grunt-parallel": "^0.5.1", 28 | "grunt-preprocess": "^5.1.0", 29 | "grunt-ts": "^6.0.0-beta.22", 30 | "grunt-typescript": "^0.8.0", 31 | "lodash": "^4.17.11", 32 | "matchdep": "^2.0.0", 33 | "tslint": "^5.18.0", 34 | "tslint-config-airbnb": "^5.11.1", 35 | "typescript": "^3.5.2" 36 | }, 37 | "dependencies": { 38 | "body-parser": "^1.19.0", 39 | "cookie-parser": "^1.4.4", 40 | "cors": "^2.8.5", 41 | "dotenv": "^8.0.0", 42 | "express": "^4.17.1", 43 | "node": "^12.5.0", 44 | "path": "^0.12.7" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /04_03_DataType_Array.ts: -------------------------------------------------------------------------------- 1 | //TypeScript Data Type - Array 2 | 3 | // An array is a special type of data type which can store 4 | // multiple values of different data types sequentially using a special syntax. 5 | 6 | // 1. Using square brackets. 7 | // let fruits: string[] = ['Apple', 'Orange', 'Banana']; 8 | 9 | // 2. Using a generic array type, Array 10 | // let fruits: Array = ['Apple', 'Orange', 'Banana']; 11 | 12 | // Example: Array Declaration and Initialization 13 | let fruits: Array; 14 | fruits = ['Apple', 'Orange', 'Banana']; 15 | 16 | let ids: Array; 17 | ids = [23, 34, 100, 124, 44]; 18 | 19 | // An array in TypeScript can contain elements of different 20 | // data types using a generic array type syntax, as shown below. 21 | let values: Array = ['Apple', 2, 'Orange', 3, 4, 'Banana']; 22 | 23 | // Example: Access Array Elements 24 | fruits[0]; // returns Apple 25 | fruits[1]; // returns Orange 26 | fruits[2]; // returns Banana 27 | fruits[3]; // returns undefined 28 | 29 | // Access Array Elements using Loop 30 | for(var index in fruits) { 31 | console.log(fruits[index]); // output: Apple Orange Banana 32 | } 33 | 34 | for(var i = 0; i < fruits.length; i++) { 35 | console.log(fruits[i]); // output: Apple Orange Banana 36 | } 37 | 38 | // Example: Array Methods 39 | fruits.sort(); 40 | console.log(fruits); //output: [ 'Apple', 'Banana', 'Orange' ] 41 | 42 | console.log(fruits.pop()); //output: Orange 43 | 44 | fruits.push('Papaya'); 45 | console.log(fruits); //output: ['Apple', 'Banana', 'Papaya'] 46 | 47 | fruits = fruits.concat(['Fig', 'Mango']); 48 | console.log(fruits); //output: ['Apple', 'Banana', 'Papaya', 'Fig', 'Mango'] 49 | 50 | console.log(fruits.indexOf('Papaya'));//output: 2 -------------------------------------------------------------------------------- /07_01_Function.ts: -------------------------------------------------------------------------------- 1 | // Functions are the primary blocks of any program. 2 | // In JavaScript, functions are the most important part since the 3 | // JavaScript is a functional programming language. 4 | 5 | // Functions ensure that the program is maintainable and reusable, and organized into readable blocks. 6 | 7 | // Named Functions 8 | // A named function is one where you declare and call a function by its given name. 9 | 10 | function display() { 11 | console.log("Hello TypeScript!"); 12 | } 13 | display(); //Output: Hello TypeScript 14 | 15 | // Example: Function with Parameter and Return Types 16 | function sum(x: number, y: number) : number { 17 | return x + y; 18 | } 19 | sum(2,3); // returns 5 20 | 21 | // Example: Anonymous Function 22 | let greeting = function() { 23 | console.log("Hello TypeScript!"); 24 | }; 25 | greeting(); //Output: Hello TypeScript! 26 | 27 | // Example: Function with Paramter and Return Types 28 | let Sum = function(x: number, y: number) : number 29 | { 30 | return x + y; 31 | } 32 | Sum(2,3); // returns 5 33 | 34 | // Optional Parameters 35 | // The parameters that may or may not receive a value can be appended with a '?' to mark them as optional. 36 | // Example: Optional Parameter 37 | function Greet(greeting: string, name?: string ) : string { 38 | return greeting + ' ' + name + '!'; 39 | } 40 | 41 | Greet('Hello','Steve');//OK, returns "Hello Steve!" 42 | Greet('Hi'); // OK, returns "Hi undefined!". 43 | Greet('Hi','Bill','Gates'); //Compiler Error: Expected 2 arguments, but got 3. 44 | 45 | // Default Parameters 46 | function Greet(name: string, greeting: string = "Hello") : string { 47 | return greeting + ' ' + name + '!'; 48 | } 49 | 50 | Greet('Steve');//OK, returns "Hello Steve!" 51 | Greet('Steve', 'Hi'); // OK, returns "Hi Steve!". 52 | Greet('Bill'); //OK, returns "Hello Bill!" -------------------------------------------------------------------------------- /09_01_Interface.ts: -------------------------------------------------------------------------------- 1 | // Interface is a structure that defines the contract in your application. 2 | // It defines the syntax for classes to follow. 3 | // Classes that are derived from an interface must follow the structure provided by their interface. 4 | 5 | // Example: Interface 6 | interface IEmployee { 7 | empCode: number; 8 | empName: string; 9 | getSalary: (number) => number; // arrow function 10 | getManagerName(number): string; 11 | } 12 | 13 | // Example: Interface as Type 14 | interface KeyPair { 15 | key: number; 16 | value: string; 17 | } 18 | 19 | let kv1: KeyPair = { key:1, value:"Steve" }; // OK 20 | let kv2: KeyPair = { key:1, val:"Steve" }; // Compiler Error: 'val' doesn't exist in type 'KeyPair' 21 | let kv3: KeyPair = { key:1, value:100 }; // Compiler Error: 22 | 23 | // Example: Optional Property 24 | interface IEmployee2 { 25 | empCode: number; 26 | empName: string; 27 | empDept?:string; 28 | } 29 | 30 | let empObj2:IEmployee2 = { // OK 31 | empCode:1, 32 | empName:"Steve" 33 | } 34 | 35 | let empObj3:IEmployee2 = { // OK 36 | empCode:1, 37 | empName:"Bill", 38 | empDept:"IT" 39 | } 40 | 41 | // Example: Readonly Property 42 | interface Citizen { 43 | name: string; 44 | readonly SSN: number; 45 | } 46 | 47 | let personObj: Citizen = { SSN: 110555444, name: 'James Bond' }; 48 | personObj.name = 'Steve Smith'; // OK 49 | personObj.SSN = '333666888'; // Compiler Error 50 | 51 | 52 | // Example: Interface Implementation 53 | interface ThisIEmployee { 54 | empCode: number; 55 | name: string; 56 | getSalary:(number)=>number; 57 | } 58 | 59 | 60 | class ContractualEmployee implements ThisIEmployee { 61 | empCode: number; 62 | name: string; 63 | 64 | constructor(code: number, name: string) { 65 | this.empCode = code; 66 | this.name = name; 67 | } 68 | 69 | getSalary(empCode:number):number { 70 | return 20000; 71 | } 72 | } 73 | 74 | let contractualEmployee = new ContractualEmployee(1, "Steve"); -------------------------------------------------------------------------------- /11_01_DataModifiers.ts: -------------------------------------------------------------------------------- 1 | // 'Encapsulation' is used to make class members public or private 2 | // i.e. a class can control the visibility of its data members. This is done using access modifiers. 3 | 4 | // Example: public and private 5 | class HardWorkingEmployee { 6 | public empCode: number; 7 | empName: string; // public by default 8 | private salary: number; 9 | } 10 | 11 | let hardWorkingEmp = new HardWorkingEmployee(); 12 | hardWorkingEmp.empCode = 123; 13 | hardWorkingEmp.empName = "Swati"; 14 | hardWorkingEmp.salary = 20000; // Compilation Error 15 | 16 | // protected access modifier is similar to the private access modifier, 17 | // except that protected members can be accessed using their deriving classes. 18 | class Employee { 19 | public empName: string; 20 | protected empCode: number; 21 | 22 | constructor(name: string, code: number){ 23 | this.empName = name; 24 | this.empCode = code; 25 | } 26 | } 27 | 28 | class SalesEmployee extends Employee{ 29 | private department: string; 30 | 31 | constructor(name: string, code: number, department: string) { 32 | super(name, code); 33 | this.department = department; 34 | } 35 | } 36 | 37 | let empObj = new SalesEmployee("John Smith", 123, "Sales"); 38 | empObj.empCode; //Compiler Error 39 | 40 | // Example: ReadOnly Class Properties 41 | class AnotherEmployee { 42 | readonly empCode: number; 43 | empName: string; 44 | 45 | constructor(code: number, name: string) { 46 | this.empCode = code; 47 | this.empName = name; 48 | } 49 | } 50 | let emp = new AnotherEmployee(10, "John"); 51 | emp.empCode = 20; //Compiler Error 52 | emp.empName = 'Bill'; //Compiler Error 53 | 54 | /* 55 | Can also be declared in an interfacce 56 | interface IEmployee { 57 | readonly empCode: number; 58 | empName: string; 59 | } 60 | 61 | let empObj:IEmployee = { 62 | empCode:1, 63 | empName:"Steve" 64 | } 65 | 66 | empObj.empCode = 100; // Compiler Error: Cannot change readonly 'empCode' 67 | */ 68 | -------------------------------------------------------------------------------- /06_01_Constructs.ts: -------------------------------------------------------------------------------- 1 | // TypeScript - if else 2 | 3 | let x: number = 10, y = 20; 4 | 5 | if (x > y) { 6 | console.log("x is greater than y."); 7 | } else if (x < y) { 8 | console.log("x is less than y."); //This will be executed 9 | } else if (x == y) { 10 | console.log("x is equal to y"); 11 | } 12 | 13 | // Ternary operator 14 | x > y? console.log('x is greater than y.'): console.log('x is less than or equal to y.') 15 | 16 | // TypeScript - switch 17 | // Example: switch 18 | let theDay : number = 4; 19 | 20 | switch (theDay) { 21 | case 0: 22 | console.log("It is a Sunday."); 23 | break; 24 | case 1: 25 | console.log("It is a Monday."); 26 | break; 27 | case 2: 28 | console.log("It is a Tuesday."); 29 | break; 30 | case 3: 31 | console.log("It is a Wednesday."); 32 | break; 33 | case 4: 34 | console.log("It is a Thursday."); 35 | break; 36 | case 5: 37 | console.log("It is a Friday."); 38 | break; 39 | case 6: 40 | console.log("It is a Saturday."); 41 | break; 42 | default: 43 | console.log("No such day exists!"); 44 | break; 45 | } 46 | 47 | // Example: for Loop 48 | for (let i = 0; i < 3; i++) { 49 | console.log ("Block statement execution no." + i); 50 | } 51 | 52 | // for...of Loop 53 | // TypeScript includes the for...of loop to iterate and access elements of 54 | // an array, list, or tuple collection 55 | //Example: for..of Loop 56 | let thatArr = [10, 20, 30, 40]; 57 | 58 | for (var val of thatArr) { 59 | console.log(val); // prints values: 10, 20, 30, 40 60 | } 61 | 62 | let helloWorld = "Hello World"; 63 | 64 | for (var char of helloWorld) { 65 | console.log(char); // prints chars: H e l l o W o r l d 66 | } 67 | 68 | // The for...in loop iterates through a list or collection and returns an index on each iteration. 69 | // Example: for..in Loop 70 | let thisArr = [10, 20, 30, 40]; 71 | 72 | for (var index in thisArr) { 73 | console.log(index); // prints indexes: 0, 1, 2, 3 74 | 75 | console.log(arr[index]); // prints elements: 10, 20, 30, 40 76 | } 77 | 78 | //Example: while loop 79 | let thisVar: number = 2; 80 | 81 | while (thisVar < 4) { 82 | console.log( "Block statement execution no." + thisVar ); 83 | thisVar++; 84 | } -------------------------------------------------------------------------------- /08_01_Class.ts: -------------------------------------------------------------------------------- 1 | /* 2 | In ECMAScript 6, object-oriented class based approach was introduced. 3 | TypeScript introduced classes to avail the benefit of object-oriented 4 | techniques like encapsulation and abstraction. 5 | The class in TypeScript is compiled to plain JavaScript functions 6 | by the TypeScript compiler to work across platforms and browsers. 7 | 8 | A class can include the following: 9 | - Constructor 10 | - Properties 11 | - Methods 12 | */ 13 | 14 | // Example: Class 15 | class Employee { 16 | empCode: number; 17 | empName: string; 18 | 19 | // the constructor method is always defined with the name "constructor" 20 | constructor(code: number, name: string) { 21 | // members of the class can be accessed using this keyword 22 | this.empName = name; 23 | this.empCode = code; 24 | } 25 | 26 | getSalary() : number { 27 | return 10000; 28 | } 29 | } 30 | 31 | // Creating an Object of Class 32 | let emp = new Employee(100, 'John Doe'); 33 | 34 | // Example: Inheritance 35 | class Person { 36 | name: string; 37 | 38 | constructor(name: string) { 39 | this.name = name; 40 | } 41 | } 42 | 43 | class RegularyEmployee extends Person { 44 | empCode: number; 45 | 46 | constructor(empcode: number, name:string) { 47 | // We must call super() method first before assigning values 48 | // to properties in the constructor of the derived class. 49 | super(name); 50 | this.empCode = empcode; 51 | } 52 | 53 | displayName():void { 54 | console.log("Name = " + this.name + ", Employee Code = " + this.empCode); 55 | } 56 | } 57 | 58 | let regularEmployee = new RegularyEmployee(100, "Bill"); 59 | regularEmployee.displayName(); // Name = Bill, Employee Code = 100 60 | 61 | // Example: Method Overriding 62 | class Car { 63 | name: string; 64 | 65 | constructor(name: string) { 66 | this.name = name; 67 | } 68 | 69 | run(speed:number = 0) { 70 | console.log("A " + this.name + " is moving at " + speed + " mph!"); 71 | } 72 | } 73 | 74 | class Mercedes extends Car { 75 | 76 | constructor(name: string) { 77 | super(name); 78 | } 79 | 80 | run(speed = 150) { 81 | console.log('A Mercedes started') 82 | super.run(speed); 83 | } 84 | } 85 | 86 | class Honda extends Car { 87 | 88 | constructor(name: string) { 89 | super(name); 90 | } 91 | 92 | run(speed = 100) { 93 | console.log('A Honda started') 94 | super.run(speed); 95 | } 96 | } 97 | 98 | let mercObj = new Mercedes("Mercedes-Benz GLA"); 99 | let hondaObj = new Honda("Honda City"); -------------------------------------------------------------------------------- /03_Variable.ts: -------------------------------------------------------------------------------- 1 | // Variable 2 | // var Declaration 3 | // Variables in TypeScript can be declared using var keyword, same as in JavaScript. 4 | // The scoping rules remains the same as in JavaScript. 5 | var hoistedVariable = 'I am on top of the world!'; 6 | // Example: var Variables Scope 7 | var num1:number = 1; 8 | 9 | function varDeclaration() { 10 | var num2:number = 2; 11 | 12 | if (num2 > num1) { 13 | var num3: number = 3; 14 | num3++; 15 | } 16 | 17 | while(num1 < num2) { 18 | var num4: number = 4; 19 | num1++; 20 | } 21 | 22 | console.log(num1); //2 23 | console.log(num2); //2 24 | console.log(num3); //4 25 | console.log(num4); //4 26 | } 27 | 28 | varDeclaration(); 29 | 30 | // Variable Declaration using let 31 | // let employeeName = "John"; or 32 | let employeeName:string = "John"; 33 | // Example: let Variables Scope 34 | function letDeclaration() { 35 | let num2:number = 2; 36 | 37 | if (num2 > num1) { 38 | let num3: number = 3; 39 | num3++; 40 | } 41 | 42 | while(num1 < num2) { 43 | let num4: number = 4; 44 | num1++; 45 | } 46 | 47 | console.log(num1); //OK 48 | console.log(num2); //OK 49 | console.log(num3); //Compiler Error: Cannot find name 'num3' 50 | console.log(num4); //Compiler Error: Cannot find name 'num4' 51 | } 52 | letDeclaration(); 53 | 54 | // Example: let vs var 55 | // 56 | console.log(letVariable); // Compiler Error: error TS2448: Block-scoped variable 'num' used before its declaration 57 | let letVariable:number = 10 ; 58 | 59 | console.log(varVariable); // OK, Output: undefined 60 | var varVariable:number = 10 ; 61 | 62 | // Variable that was already passed in as an argument to the function 63 | function letDemo(a: number ) { 64 | let a:number = 10 ; //Compiler Error: TS2300: Duplicate identifier 'a' 65 | let b:number = 20 ; 66 | 67 | return a + b ; 68 | } 69 | 70 | // Const Declaration 71 | // - Const variables must be declared and initialized in a single statement 72 | // - Separate declaration and initialization is not supported. 73 | const constantVar:number = 100; 74 | constantVar = 200; //Compiler Error: Cannot assign to 'constantVar' because it is a constant or read-only property 75 | 76 | // Const variables allow an object sub-properties to be changed but not the object structure. 77 | const playerCodes = { 78 | player1 : 9, 79 | player2 : 10, 80 | player3 : 13, 81 | player4 : 20 82 | }; 83 | playerCodes.player2 = 11; // OK 84 | 85 | playerCodes = { //Compiler Error: Cannot assign to playerCodes because it is a constant or read-only 86 | player1 : 50, // Modified value 87 | player2 : 10, 88 | player3 : 13, 89 | player4 : 20 90 | }; 91 | 92 | // Type Inference in TypeScript 93 | var a = "some text"; 94 | var b = 123; 95 | a = b; // Compiler Error: Type 'number' is not assignable to type 'string' -------------------------------------------------------------------------------- /04_02_DataType_String.ts: -------------------------------------------------------------------------------- 1 | // String is a primitive data type that is used to store text data. 2 | // String values are surrounded by single quotation marks or double quotation marks. 3 | 4 | // let employeeName:string = 'John Smith'; 5 | //OR 6 | let employeeName:string = "John Smith"; 7 | 8 | // Template String 9 | let employeeDept:string = "Finance"; 10 | 11 | // Pre-ES6 12 | let employeeDesc1: string = employeeName + " works in the " + employeeDept + " department."; 13 | 14 | // Post-ES6 15 | let employeeDesc2: string = `${employeeName} works in the ${employeeDept} department.`; 16 | 17 | console.log(employeeDesc1);//John Smith works in the Finance department. 18 | console.log(employeeDesc2);//John Smith works in the Finance department. 19 | 20 | // string functions 21 | // The charAt() method returns a character at the specified index from a string. 22 | let str: string = 'Hello TypeScript'; 23 | str.charAt(0); // returns 'H' 24 | str.charAt(2); // returns 'l' 25 | "Hello World".charAt(2); // returns l 26 | 27 | // The concat() method concatenates two or more specified strings. 28 | let str1: string = 'Hello'; 29 | let str2: string = 'TypeScript'; 30 | str1.concat(str2); // returns 'HelloTypeScript' 31 | str1.concat(' ', str2); // returns 'Hello TypeScript' 32 | str1.concat(' Mr. ', 'Bond'); // returns 'Hello Mr. Bond' 33 | 34 | // The indexOf() method returns an index of first occurrence of the specified sub string from a string. 35 | // The index starts from 0. It returns -1 if not found. 36 | // The indexOf() method search is case-sensitive. 37 | let str3: string = 'TypeScript'; 38 | 39 | str3.indexOf('T'); // returns 0 40 | str3.indexOf('p'); // returns 2 41 | str3.indexOf('e'); // returns 3 42 | str3.indexOf('T', 1); // returns -1 43 | str3.indexOf('t', 1); // returns 9 44 | 45 | // The replace() method replaces the matched substring with the specified string. 46 | let str4: string = 'Hello Javascript'; 47 | let str5: string = 'TypeScript'; 48 | 49 | str4.replace('Java', 'Type'); // returns 'Hello TypeScript' 50 | str4.replace('JavaScript', str5); // returns 'Hello TypeScript' 51 | str4.replace(/Hello/gi, 'Hi'); // returns 'Hi TypeScript' 52 | 53 | // The split() method splits a string into substrings based on a specified separator character 54 | // and returns an array of substrings. 55 | let str6: string = 'Apple, Banana, Orange'; 56 | let str7: string = ','; 57 | 58 | str6.split(str7) // returns [ 'Apple', ' Banana', ' Orange' ] 59 | str6.split(',') // returns [ 'Apple', ' Banana', ' Orange' ] 60 | str6.split(',', 2) // returns [ 'Apple', ' Banana' ] 61 | str6.split(',', 1) // returns [ 'Apple'] 62 | 63 | // The toUpperCase() method returns an upper case representation of the string 64 | let typeString: string = 'Hello Typescript'; 65 | typeString.toUpperCase(); // returns 'HELLO TYPESCRIPT' 66 | 'hello typescript'.toUpperCase(); // returns 'HELLO TYPESCRIPT' 67 | 68 | // The toLowerCase() method returns a lower case representation of the string 69 | typeString.toLowerCase(); // returns hello typescript 70 | 'HELLO TYPESCRIPT'.toLowerCase(); // returns hello typescript 71 | 72 | // Boolean values are supported by both JavaScript and TypeScript and stored as true/false values. 73 | let isPresent:boolean = true; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node,linux,windows,angular 3 | # Edit at https://www.gitignore.io/?templates=node,linux,windows,angular 4 | 5 | ### Angular ### 6 | ## Angular ## 7 | # compiled output 8 | /dist 9 | /tmp 10 | /app/**/*.js 11 | /app/**/*.js.map 12 | 13 | # dependencies 14 | /node_modules 15 | /bower_components 16 | 17 | # IDEs and editors 18 | /.idea 19 | 20 | # misc 21 | /.sass-cache 22 | /connect.lock 23 | /coverage/* 24 | /libpeerconnection.log 25 | npm-debug.log 26 | testem.log 27 | /typings 28 | 29 | # e2e 30 | /e2e/*.js 31 | /e2e/*.map 32 | 33 | #System Files 34 | .DS_Store 35 | 36 | ### Linux ### 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | ### Node ### 52 | # Logs 53 | logs 54 | *.log 55 | npm-debug.log* 56 | yarn-debug.log* 57 | yarn-error.log* 58 | lerna-debug.log* 59 | 60 | # Diagnostic reports (https://nodejs.org/api/report.html) 61 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 62 | 63 | # Runtime data 64 | pids 65 | *.pid 66 | *.seed 67 | *.pid.lock 68 | 69 | # Directory for instrumented libs generated by jscoverage/JSCover 70 | lib-cov 71 | 72 | # Coverage directory used by tools like istanbul 73 | coverage 74 | *.lcov 75 | 76 | # nyc test coverage 77 | .nyc_output 78 | 79 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 80 | .grunt 81 | 82 | # Bower dependency directory (https://bower.io/) 83 | bower_components 84 | 85 | # node-waf configuration 86 | .lock-wscript 87 | 88 | # Compiled binary addons (https://nodejs.org/api/addons.html) 89 | build/Release 90 | 91 | # Dependency directories 92 | node_modules/ 93 | jspm_packages/ 94 | 95 | # TypeScript v1 declaration files 96 | typings/ 97 | 98 | # TypeScript cache 99 | *.tsbuildinfo 100 | 101 | # Optional npm cache directory 102 | .npm 103 | 104 | # Optional eslint cache 105 | .eslintcache 106 | 107 | # Optional REPL history 108 | .node_repl_history 109 | 110 | # Output of 'npm pack' 111 | *.tgz 112 | 113 | # Yarn Integrity file 114 | .yarn-integrity 115 | 116 | # dotenv environment variables file 117 | .env 118 | .env.test 119 | 120 | # parcel-bundler cache (https://parceljs.org/) 121 | .cache 122 | 123 | # next.js build output 124 | .next 125 | 126 | # nuxt.js build output 127 | .nuxt 128 | 129 | # vuepress build output 130 | .vuepress/dist 131 | 132 | # Serverless directories 133 | .serverless/ 134 | 135 | # FuseBox cache 136 | .fusebox/ 137 | 138 | # DynamoDB Local files 139 | .dynamodb/ 140 | 141 | ### Windows ### 142 | # Windows thumbnail cache files 143 | Thumbs.db 144 | Thumbs.db:encryptable 145 | ehthumbs.db 146 | ehthumbs_vista.db 147 | 148 | # Dump file 149 | *.stackdump 150 | 151 | # Folder config file 152 | [Dd]esktop.ini 153 | 154 | # Recycle Bin used on file shares 155 | $RECYCLE.BIN/ 156 | 157 | # Windows Installer files 158 | *.cab 159 | *.msi 160 | *.msix 161 | *.msm 162 | *.msp 163 | 164 | # Windows shortcuts 165 | *.lnk 166 | 167 | # End of https://www.gitignore.io/api/node,linux,windows,angular 168 | -------------------------------------------------------------------------------- /14_module_demo/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | // Load Grunt tasks declared in the package.json file. 3 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); 4 | 5 | grunt.initConfig({ 6 | pkg: grunt.file.readJSON('package.json'), 7 | 8 | DEVELOPMENT_PATH: './src/', 9 | DISTRIBUTION_PATH: './bin/', 10 | 11 | /** 12 | * The different constant names that will be use to build our html files. 13 | * @example 14 | */ 15 | env: { 16 | src: { 17 | NODE_ENV : 'local' 18 | }, 19 | dev: { 20 | src : ".env" 21 | } 22 | }, 23 | 24 | preprocess : { 25 | // Task to create the index.html file that will be used during development. 26 | // Passes the app version and creates the /index.html 27 | src : { 28 | src : './public/index.html', 29 | dest : '<%= DISTRIBUTION_PATH %>' + '/public/index.html', 30 | options : { 31 | context : { 32 | APP_VERSION : '<%= pkg.version %>', 33 | APP_ENV: '<%= __ENV.NODE_ENV %>' 34 | } 35 | } 36 | } 37 | }, 38 | 39 | /** 40 | * Creates a node.js Express Server to test our code in a server like environment. 41 | * Note: We are using the watch task to keep the server running. 42 | */ 43 | express: { 44 | start: { 45 | options: { 46 | script: '<%= DISTRIBUTION_PATH %>' + 'app.js', 47 | } 48 | } 49 | }, 50 | 51 | watch: { 52 | src: { 53 | options: { 54 | livereload: true 55 | }, 56 | files: [ 57 | '<%= DEVELOPMENT_PATH %>' + '**/*.ts', 58 | '<%= DEVELOPMENT_PATH %>' + 'index.template.html' 59 | ], 60 | tasks: ['src'] 61 | } 62 | }, 63 | 64 | copy: { 65 | web: { 66 | files: [ 67 | { expand: true, cwd: 'public', src: 'favicon.ico', dest: '<%= DISTRIBUTION_PATH %>/public' }, 68 | { expand: true, cwd: 'public', src: ['media/**/*'], dest: '<%= DISTRIBUTION_PATH %>/public' } 69 | ] 70 | } 71 | }, 72 | 73 | /** 74 | * Cleans or deletes our production folder before we create a new production build. 75 | */ 76 | clean: { 77 | web: ['<%= DISTRIBUTION_PATH %>' + '/**/*'] 78 | }, 79 | 80 | ts: { 81 | default : { 82 | tsconfig: './tsconfig.json' 83 | } 84 | }, 85 | 86 | open : { 87 | dev : { 88 | path: 'http://127.0.0.1:8000' 89 | } 90 | } 91 | 92 | }); 93 | 94 | grunt.registerTask('default', [ 95 | 'local' 96 | ]); 97 | 98 | grunt.registerTask('local', [ 99 | 'env:src', 100 | 'server' 101 | ]); 102 | 103 | grunt.registerTask('dev', [ 104 | 'env:dev', 105 | 'server' 106 | ]); 107 | 108 | grunt.registerTask('server', [ 109 | 'clean', 110 | 'copy:web', 111 | 'set-env', 112 | 'preprocess:src', 113 | 'ts', 114 | 'express:start', 115 | 'open', 116 | 'watch' 117 | ]); 118 | 119 | grunt.registerTask('set-env', 'set_environment_variables', function() { 120 | grunt.config('__ENV', process.env); 121 | }); 122 | } -------------------------------------------------------------------------------- /14_module_demo/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node,linux,macos,windows,angular 3 | # Edit at https://www.gitignore.io/?templates=node,linux,macos,windows,angular 4 | 5 | ### Angular ### 6 | ## Angular ## 7 | # compiled output 8 | /dist 9 | /tmp 10 | /app/**/*.js 11 | /app/**/*.js.map 12 | 13 | # dependencies 14 | /node_modules 15 | /bower_components 16 | 17 | # IDEs and editors 18 | /.idea 19 | 20 | # misc 21 | /.sass-cache 22 | /connect.lock 23 | /coverage/* 24 | /libpeerconnection.log 25 | npm-debug.log 26 | testem.log 27 | /typings 28 | 29 | # e2e 30 | /e2e/*.js 31 | /e2e/*.map 32 | 33 | #System Files 34 | .DS_Store 35 | 36 | ### Linux ### 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | ### macOS ### 52 | # General 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | ### Node ### 79 | # Logs 80 | logs 81 | *.log 82 | npm-debug.log* 83 | yarn-debug.log* 84 | yarn-error.log* 85 | lerna-debug.log* 86 | 87 | # Diagnostic reports (https://nodejs.org/api/report.html) 88 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 89 | 90 | # Runtime data 91 | pids 92 | *.pid 93 | *.seed 94 | *.pid.lock 95 | 96 | # Directory for instrumented libs generated by jscoverage/JSCover 97 | lib-cov 98 | 99 | # Coverage directory used by tools like istanbul 100 | coverage 101 | *.lcov 102 | 103 | # nyc test coverage 104 | .nyc_output 105 | 106 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 107 | .grunt 108 | 109 | # Bower dependency directory (https://bower.io/) 110 | bower_components 111 | 112 | # node-waf configuration 113 | .lock-wscript 114 | 115 | # Compiled binary addons (https://nodejs.org/api/addons.html) 116 | build/Release 117 | 118 | # Dependency directories 119 | node_modules/ 120 | jspm_packages/ 121 | 122 | # TypeScript v1 declaration files 123 | typings/ 124 | 125 | # TypeScript cache 126 | *.tsbuildinfo 127 | 128 | # Optional npm cache directory 129 | .npm 130 | 131 | # Optional eslint cache 132 | .eslintcache 133 | 134 | # Optional REPL history 135 | .node_repl_history 136 | 137 | # Output of 'npm pack' 138 | *.tgz 139 | 140 | # Yarn Integrity file 141 | .yarn-integrity 142 | 143 | # dotenv environment variables file 144 | .env 145 | .env.test 146 | 147 | # parcel-bundler cache (https://parceljs.org/) 148 | .cache 149 | 150 | # next.js build output 151 | .next 152 | 153 | # nuxt.js build output 154 | .nuxt 155 | 156 | # vuepress build output 157 | .vuepress/dist 158 | 159 | # Serverless directories 160 | .serverless/ 161 | 162 | # FuseBox cache 163 | .fusebox/ 164 | 165 | # DynamoDB Local files 166 | .dynamodb/ 167 | 168 | ### Windows ### 169 | # Windows thumbnail cache files 170 | Thumbs.db 171 | Thumbs.db:encryptable 172 | ehthumbs.db 173 | ehthumbs_vista.db 174 | 175 | # Dump file 176 | *.stackdump 177 | 178 | # Folder config file 179 | [Dd]esktop.ini 180 | 181 | # Recycle Bin used on file shares 182 | $RECYCLE.BIN/ 183 | 184 | # Windows Installer files 185 | *.cab 186 | *.msi 187 | *.msix 188 | *.msm 189 | *.msp 190 | 191 | # Windows shortcuts 192 | *.lnk 193 | 194 | # End of https://www.gitignore.io/api/node,linux,macos,windows,angular -------------------------------------------------------------------------------- /FirstProject/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "FirstProject", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@babel/code-frame": { 8 | "version": "7.0.0", 9 | "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", 10 | "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", 11 | "dev": true, 12 | "requires": { 13 | "@babel/highlight": "^7.0.0" 14 | } 15 | }, 16 | "@babel/highlight": { 17 | "version": "7.0.0", 18 | "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", 19 | "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", 20 | "dev": true, 21 | "requires": { 22 | "chalk": "^2.0.0", 23 | "esutils": "^2.0.2", 24 | "js-tokens": "^4.0.0" 25 | } 26 | }, 27 | "@fimbul/bifrost": { 28 | "version": "0.17.0", 29 | "resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.17.0.tgz", 30 | "integrity": "sha512-gVTkJAOef5HtN6LPmrtt5fAUmBywwlgmObsU3FBhPoNeXPLaIl2zywXkJEtvvVLQnaFmtff3x+wIj5lHRCDE3Q==", 31 | "requires": { 32 | "@fimbul/ymir": "^0.17.0", 33 | "get-caller-file": "^2.0.0", 34 | "tslib": "^1.8.1", 35 | "tsutils": "^3.5.0" 36 | }, 37 | "dependencies": { 38 | "tsutils": { 39 | "version": "3.14.0", 40 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", 41 | "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", 42 | "requires": { 43 | "tslib": "^1.8.1" 44 | } 45 | } 46 | } 47 | }, 48 | "@fimbul/ymir": { 49 | "version": "0.17.0", 50 | "resolved": "https://registry.npmjs.org/@fimbul/ymir/-/ymir-0.17.0.tgz", 51 | "integrity": "sha512-xMXM9KTXRLHLVS6dnX1JhHNEkmWHcAVCQ/4+DA1KKwC/AFnGHzu/7QfQttEPgw3xplT+ILf9e3i64jrFwB3JtA==", 52 | "requires": { 53 | "inversify": "^5.0.0", 54 | "reflect-metadata": "^0.1.12", 55 | "tslib": "^1.8.1" 56 | } 57 | }, 58 | "ansi-styles": { 59 | "version": "3.2.1", 60 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 61 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 62 | "dev": true, 63 | "requires": { 64 | "color-convert": "^1.9.0" 65 | } 66 | }, 67 | "argparse": { 68 | "version": "1.0.10", 69 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 70 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 71 | "dev": true, 72 | "requires": { 73 | "sprintf-js": "~1.0.2" 74 | } 75 | }, 76 | "balanced-match": { 77 | "version": "1.0.0", 78 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 79 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 80 | "dev": true 81 | }, 82 | "brace-expansion": { 83 | "version": "1.1.11", 84 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 85 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 86 | "dev": true, 87 | "requires": { 88 | "balanced-match": "^1.0.0", 89 | "concat-map": "0.0.1" 90 | } 91 | }, 92 | "builtin-modules": { 93 | "version": "1.1.1", 94 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", 95 | "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", 96 | "dev": true 97 | }, 98 | "chalk": { 99 | "version": "2.4.2", 100 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 101 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 102 | "dev": true, 103 | "requires": { 104 | "ansi-styles": "^3.2.1", 105 | "escape-string-regexp": "^1.0.5", 106 | "supports-color": "^5.3.0" 107 | } 108 | }, 109 | "color-convert": { 110 | "version": "1.9.3", 111 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 112 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 113 | "dev": true, 114 | "requires": { 115 | "color-name": "1.1.3" 116 | } 117 | }, 118 | "color-name": { 119 | "version": "1.1.3", 120 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 121 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 122 | "dev": true 123 | }, 124 | "commander": { 125 | "version": "2.20.0", 126 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", 127 | "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", 128 | "dev": true 129 | }, 130 | "concat-map": { 131 | "version": "0.0.1", 132 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 133 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 134 | "dev": true 135 | }, 136 | "diff": { 137 | "version": "3.5.0", 138 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 139 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 140 | "dev": true 141 | }, 142 | "doctrine": { 143 | "version": "0.7.2", 144 | "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", 145 | "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", 146 | "requires": { 147 | "esutils": "^1.1.6", 148 | "isarray": "0.0.1" 149 | }, 150 | "dependencies": { 151 | "esutils": { 152 | "version": "1.1.6", 153 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", 154 | "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=" 155 | } 156 | } 157 | }, 158 | "escape-string-regexp": { 159 | "version": "1.0.5", 160 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 161 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 162 | "dev": true 163 | }, 164 | "esprima": { 165 | "version": "4.0.1", 166 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 167 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 168 | "dev": true 169 | }, 170 | "esutils": { 171 | "version": "2.0.2", 172 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", 173 | "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", 174 | "dev": true 175 | }, 176 | "fs.realpath": { 177 | "version": "1.0.0", 178 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 179 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 180 | "dev": true 181 | }, 182 | "get-caller-file": { 183 | "version": "2.0.5", 184 | "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", 185 | "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" 186 | }, 187 | "glob": { 188 | "version": "7.1.4", 189 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", 190 | "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", 191 | "dev": true, 192 | "requires": { 193 | "fs.realpath": "^1.0.0", 194 | "inflight": "^1.0.4", 195 | "inherits": "2", 196 | "minimatch": "^3.0.4", 197 | "once": "^1.3.0", 198 | "path-is-absolute": "^1.0.0" 199 | } 200 | }, 201 | "has-flag": { 202 | "version": "3.0.0", 203 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 204 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 205 | "dev": true 206 | }, 207 | "inflight": { 208 | "version": "1.0.6", 209 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 210 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 211 | "dev": true, 212 | "requires": { 213 | "once": "^1.3.0", 214 | "wrappy": "1" 215 | } 216 | }, 217 | "inherits": { 218 | "version": "2.0.4", 219 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 220 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 221 | "dev": true 222 | }, 223 | "inversify": { 224 | "version": "5.0.1", 225 | "resolved": "https://registry.npmjs.org/inversify/-/inversify-5.0.1.tgz", 226 | "integrity": "sha512-Ieh06s48WnEYGcqHepdsJUIJUXpwH5o5vodAX+DK2JA/gjy4EbEcQZxw+uFfzysmKjiLXGYwNG3qDZsKVMcINQ==" 227 | }, 228 | "isarray": { 229 | "version": "0.0.1", 230 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", 231 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" 232 | }, 233 | "js-tokens": { 234 | "version": "4.0.0", 235 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 236 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", 237 | "dev": true 238 | }, 239 | "js-yaml": { 240 | "version": "3.13.1", 241 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 242 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 243 | "dev": true, 244 | "requires": { 245 | "argparse": "^1.0.7", 246 | "esprima": "^4.0.0" 247 | } 248 | }, 249 | "minimatch": { 250 | "version": "3.0.4", 251 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 252 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 253 | "dev": true, 254 | "requires": { 255 | "brace-expansion": "^1.1.7" 256 | } 257 | }, 258 | "minimist": { 259 | "version": "0.0.8", 260 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 261 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 262 | "dev": true 263 | }, 264 | "mkdirp": { 265 | "version": "0.5.1", 266 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 267 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 268 | "dev": true, 269 | "requires": { 270 | "minimist": "0.0.8" 271 | } 272 | }, 273 | "once": { 274 | "version": "1.4.0", 275 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 276 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 277 | "dev": true, 278 | "requires": { 279 | "wrappy": "1" 280 | } 281 | }, 282 | "path-is-absolute": { 283 | "version": "1.0.1", 284 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 285 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 286 | "dev": true 287 | }, 288 | "path-parse": { 289 | "version": "1.0.6", 290 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 291 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 292 | "dev": true 293 | }, 294 | "reflect-metadata": { 295 | "version": "0.1.13", 296 | "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", 297 | "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==" 298 | }, 299 | "resolve": { 300 | "version": "1.11.1", 301 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", 302 | "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", 303 | "dev": true, 304 | "requires": { 305 | "path-parse": "^1.0.6" 306 | } 307 | }, 308 | "semver": { 309 | "version": "5.7.0", 310 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", 311 | "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", 312 | "dev": true 313 | }, 314 | "sprintf-js": { 315 | "version": "1.0.3", 316 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 317 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 318 | "dev": true 319 | }, 320 | "supports-color": { 321 | "version": "5.5.0", 322 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 323 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 324 | "dev": true, 325 | "requires": { 326 | "has-flag": "^3.0.0" 327 | } 328 | }, 329 | "tslib": { 330 | "version": "1.10.0", 331 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", 332 | "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" 333 | }, 334 | "tslint": { 335 | "version": "5.18.0", 336 | "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.18.0.tgz", 337 | "integrity": "sha512-Q3kXkuDEijQ37nXZZLKErssQVnwCV/+23gFEMROi8IlbaBG6tXqLPQJ5Wjcyt/yHPKBC+hD5SzuGaMora+ZS6w==", 338 | "dev": true, 339 | "requires": { 340 | "@babel/code-frame": "^7.0.0", 341 | "builtin-modules": "^1.1.1", 342 | "chalk": "^2.3.0", 343 | "commander": "^2.12.1", 344 | "diff": "^3.2.0", 345 | "glob": "^7.1.1", 346 | "js-yaml": "^3.13.1", 347 | "minimatch": "^3.0.4", 348 | "mkdirp": "^0.5.1", 349 | "resolve": "^1.3.2", 350 | "semver": "^5.3.0", 351 | "tslib": "^1.8.0", 352 | "tsutils": "^2.29.0" 353 | } 354 | }, 355 | "tslint-config-airbnb": { 356 | "version": "5.11.1", 357 | "resolved": "https://registry.npmjs.org/tslint-config-airbnb/-/tslint-config-airbnb-5.11.1.tgz", 358 | "integrity": "sha512-hkaittm2607vVMe8eotANGN1CimD5tor7uoY3ypg2VTtEcDB/KGWYbJOz58t8LI4cWSyWtgqYQ5F0HwKxxhlkQ==", 359 | "requires": { 360 | "tslint-consistent-codestyle": "^1.14.1", 361 | "tslint-eslint-rules": "^5.4.0", 362 | "tslint-microsoft-contrib": "~5.2.1" 363 | } 364 | }, 365 | "tslint-consistent-codestyle": { 366 | "version": "1.15.1", 367 | "resolved": "https://registry.npmjs.org/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.15.1.tgz", 368 | "integrity": "sha512-38Y3Dz4zcABe/PlPAQSGNEWPGVq0OzcIQR7SEU6dNujp/SgvhxhJOhIhI9gY4r0I3/TNtvVQwARWor9O9LPZWg==", 369 | "requires": { 370 | "@fimbul/bifrost": "^0.17.0", 371 | "tslib": "^1.7.1", 372 | "tsutils": "^2.29.0" 373 | } 374 | }, 375 | "tslint-eslint-rules": { 376 | "version": "5.4.0", 377 | "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz", 378 | "integrity": "sha512-WlSXE+J2vY/VPgIcqQuijMQiel+UtmXS+4nvK4ZzlDiqBfXse8FAvkNnTcYhnQyOTW5KFM+uRRGXxYhFpuBc6w==", 379 | "requires": { 380 | "doctrine": "0.7.2", 381 | "tslib": "1.9.0", 382 | "tsutils": "^3.0.0" 383 | }, 384 | "dependencies": { 385 | "tslib": { 386 | "version": "1.9.0", 387 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", 388 | "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==" 389 | }, 390 | "tsutils": { 391 | "version": "3.14.0", 392 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", 393 | "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", 394 | "requires": { 395 | "tslib": "^1.8.1" 396 | } 397 | } 398 | } 399 | }, 400 | "tslint-microsoft-contrib": { 401 | "version": "5.2.1", 402 | "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.2.1.tgz", 403 | "integrity": "sha512-PDYjvpo0gN9IfMULwKk0KpVOPMhU6cNoT9VwCOLeDl/QS8v8W2yspRpFFuUS7/c5EIH/n8ApMi8TxJAz1tfFUA==", 404 | "requires": { 405 | "tsutils": "^2.27.2 <2.29.0" 406 | }, 407 | "dependencies": { 408 | "tsutils": { 409 | "version": "2.28.0", 410 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.28.0.tgz", 411 | "integrity": "sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==", 412 | "requires": { 413 | "tslib": "^1.8.1" 414 | } 415 | } 416 | } 417 | }, 418 | "tsutils": { 419 | "version": "2.29.0", 420 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", 421 | "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", 422 | "requires": { 423 | "tslib": "^1.8.1" 424 | } 425 | }, 426 | "typescript": { 427 | "version": "3.5.2", 428 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", 429 | "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", 430 | "dev": true 431 | }, 432 | "wrappy": { 433 | "version": "1.0.2", 434 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 435 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 436 | "dev": true 437 | } 438 | } 439 | } 440 | --------------------------------------------------------------------------------