├── 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 |