├── .gitignore
├── .vscode
└── settings.json
├── README.md
├── basics
├── helloworld-html
│ ├── helloworld.ts
│ └── index.html
├── objects.ts
├── strong-typing.ts
├── syntatic-sugar.ts
├── type-coercion.ts
└── type_juggling.ts
├── interfaces
├── Point.ts
├── Readme.md
├── inherits.ts
├── interfaces.ts
└── todo.ts
├── package.json
├── pnpm-lock.yaml
├── practice
├── jquery
│ ├── example1.ts
│ ├── index.html
│ └── package.json
└── types_browser
│ ├── app.ts
│ └── index.html
├── src
├── basics
│ ├── datatypes.ts
│ ├── dynamic_static.ts
│ ├── type_interence.ts
│ └── union_types.ts
├── classes
│ ├── Person.ts
│ ├── Point.ts
│ ├── User.ts
│ ├── class_interfaces.ts
│ ├── constructor.ts
│ ├── inheritance.ts
│ ├── methods.ts
│ └── pending_example.ts
├── functions
│ └── index.ts
├── generics.ts
├── helloworld
│ └── helloworld.ts
├── index.ts
├── interfaces
│ └── index.ts
└── types
│ ├── ambient_declarations.ts
│ ├── block_scope.ts
│ ├── type_aliases.ts
│ └── type_guards.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | /**/*.js
2 | dist
3 |
4 | node_modules
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "typescript.tsdk": "node_modules/typescript/lib",
3 | "files.exclude": {
4 | "**/.git": true,
5 | "**/.svn": true,
6 | "**/.hg": true,
7 | "**/CVS": true,
8 | "**/.DS_Store": true,
9 | "**/Thumbs.db": true,
10 | "node_modules": true
11 | }
12 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## TypeScript Course
2 |
3 | ## Requirements
4 | - Optional: HTML, CSS, JS
5 | - Node.js and Npm
6 | - Console / Terminal Usage
7 |
8 | # Useful Commands
9 | - to transpile: `tsc myfile.ts`
10 | - all files: `tsc *.ts`
11 | - target Option: `--target ES5`
12 | - to execute your transpiled file: `node myfile.js`, because is js you can use it on whatever js enviroment
13 |
14 | ## Considerations
15 | - Ts will generate an output JS, even with errors
16 |
17 | ## More Info
18 | - (Typescript Github)[]
19 | - typescript components
20 | - compile or transpile?
21 |
22 | ## Tools:
23 | - [TS PlayGround](https://www.typescriptlang.org/play/index.html)
24 | - Intellisense
25 | - typescript(npm or yarn)
26 | - Visual Studio
27 | - vsCode
28 |
29 | ## You can Learn from this Code
30 | - transpile a .ts file to .js file
31 | - basics
32 | - hello world
33 | - strong typing
34 | - syntatic sugar
35 | - types or optional static type annotation
36 | - scope variables
37 | - avoid type juggling
38 | - type coercion
39 | - types
40 | - ts added optional static type annotation to js
41 | - transform it in a strongly typed programming language
42 | - functions
43 | - objects
44 | - ambient declarations
45 |
46 | - interfaces
47 | - clases: Person.ts
48 | - enums
49 | - modules
50 | - generic types
51 |
52 | - file extension .d.ts, third libs compatibility
53 |
54 | - type coercion
55 | - tsconfig.json
56 |
57 | ## Appendix
58 | - how to debuggin ts file with vs Code
59 | - configure tsconfig.json
60 | - how to configure ts compiler with visual studio Code
61 | - go to "Open User Settings"
62 | - go to settings.json at "typescript.sdk", by default the property has the value null
63 | - obtain where is installed npm modules: `npm root -g`
64 | - append the path with /typescript/lib as SDK path
65 | - to configure a build task
66 | - to configure Tasks: `Ctrl + shift + P` > Tasks > Typescript
67 | - to execute: `Ctrl/cmd + Shift + B`
68 | - how to ignore js outputs from ts
69 |
--------------------------------------------------------------------------------
/basics/helloworld-html/helloworld.ts:
--------------------------------------------------------------------------------
1 | var p = document.createElement("p");
2 |
3 | var hello: string = "hola";
4 | var world: string = "world";
5 |
6 | //var dos:any = 2;
7 |
8 | p.textContent = hello + " " + world;
9 |
10 | document.body.appendChild(p);
11 |
--------------------------------------------------------------------------------
/basics/helloworld-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hola Mundo con Typescript
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/basics/objects.ts:
--------------------------------------------------------------------------------
1 | // object type annotation
2 | var person: {
3 | name: string;
4 | heighInCentimeters: number;
5 | };
6 | // implementation of a person object
7 |
8 | person= {
9 | name: 'Isaac',
10 | heighInCentimeters: 181
11 | };
--------------------------------------------------------------------------------
/basics/strong-typing.ts:
--------------------------------------------------------------------------------
1 | // js allow us, any
2 | var test:any = "this is a string";
3 |
4 | test = 1;
5 |
6 | test = function(a, b) {
7 | return a + b;
8 | }
9 |
10 |
11 |
--------------------------------------------------------------------------------
/basics/syntatic-sugar.ts:
--------------------------------------------------------------------------------
1 | // :string is a type annotation
2 | var test: string = "this is a string";
3 |
4 |
--------------------------------------------------------------------------------
/basics/type-coercion.ts:
--------------------------------------------------------------------------------
1 | var oneNumber = 1;
2 | var oneString = "1";
3 |
4 | // var theSame = oneNumber == oneString; //invalid
5 | var theSame = oneNumber.toString() == oneString; //valid
6 |
7 | var thisIsAString = 1 + "1"; //11
8 | var thisIsANumber = 1 + parseInt("1", 10);//2
9 |
10 |
--------------------------------------------------------------------------------
/basics/type_juggling.ts:
--------------------------------------------------------------------------------
1 | var num = 1;
2 | var str = '0';
3 |
4 | // the result is 10 not 1
5 | var strTen = num + str;
6 |
7 | // the ressult is 20
8 | //var result = strTen * 2;
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/interfaces/Point.ts:
--------------------------------------------------------------------------------
1 | interface IPoint {
2 | x:number;
3 | y:number;
4 | }
5 |
6 | interface ICompare {
7 | Compare(p2:IPoint):number;
8 | }
9 |
10 | class Point implements IPoint, ICompare {
11 | public x:number;
12 | public y:number;
13 |
14 | constructor(x:number, y=0){
15 | this.x = x;
16 | this.y = y;
17 | }
18 |
19 | public Compare(p2:IPoint):number {
20 | var p1Val = this.x * this.x + this.y * this.y;
21 | var p2Val = p2.x * p2.x + p2.y * p2.y;
22 | var result = p1Val - p2Val;
23 | if (result == 0){
24 | return 0;
25 | } else if(result > 0) {
26 | return 1;
27 | } else {
28 | return -1;
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/interfaces/Readme.md:
--------------------------------------------------------------------------------
1 | - instalacion de typescript: `sudo npm install -g typescript`
2 | - comprobar version: `tsc --version`
3 | - compilacion de .ts a .js
4 | - types: explicado en el archivo tipos.ts
5 | - functions: archivo llamado funciones.ts
6 | - interface: archivo llamado interfaces.ts
7 | - classes
8 | - Eums
9 | - Modules
10 | - generic types
--------------------------------------------------------------------------------
/interfaces/inherits.ts:
--------------------------------------------------------------------------------
1 |
2 | // interfaces have the ability to inherit
3 | // from another interfaces
4 | // trougth 'extends' clause
5 | interface IAdder {
6 | add(arg1: number, ...args:number[]):number;
7 | }
8 |
9 | interface ISubtractor {
10 | subtract(arg1: number, ...args:number[]):number;
11 | }
12 |
13 | interface ICalculator extends IAdder, ISubtractor {
14 | multiply(arg1:number, ...args:number[]):number;
15 | divide(arg1:number, ...args:number[]):number;
16 | }
17 |
18 | // this is equivalent to the previous example
19 | interface ICalculator extends IAdder {
20 | multiply(arg1: number, ...args:number[]):number;
21 | }
22 |
23 | interface ICalculator extends ISubtractor {
24 | divide(arg1: number, ...args:number[]):number;
25 | }
26 |
27 | // implementation
28 | function performCalculations(calculator:ICalculator, num1, num2){
29 | calculator.add(num1, num2);
30 | calculator.subtract(num1, num2);
31 | calculator.multiply(num1, num2);
32 | calculator.divide(num1, num2);
33 | return true;
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/interfaces/interfaces.ts:
--------------------------------------------------------------------------------
1 | // if a type annotation becomes to complex
2 | // you can create an interface to represent
3 | // the type to simplify annotations
4 | // also is reusable
5 | // are not limite to objets
6 | // they can describe any structure
7 |
8 | interface IPerson {
9 | name: string;
10 | heighInCentimeters: number;
11 | }
12 | var myperson:IPerson = {
13 | name:'Mark',
14 | heighInCentimeters: 181
15 | }
16 |
17 | interface IPoint {
18 | x: number,
19 | y: number
20 | }
21 |
22 | interface ICompare {
23 | compare(p2: IPoint):number;
24 | }
25 |
26 |
27 | // las interfaces se pueden heredar a traves de la clausula "extends"
28 |
29 | interface ISumador {
30 | sumar(arg1:number, ...args:number[]):number;
31 | }
32 |
33 | interface ISubstrator {
34 | restar(arg1:number, ...args:number[]):number;
35 | }
36 |
37 | /*
38 | interface ICalculador extends ISumador, ISubstrator{
39 | multiplicar(arg1:number, ...args:number[]):number;
40 | dividir(arg1:number, arg2:number):number;
41 | }
42 | */
43 | // luego podemos usarla en una funcion
44 | function ejecutaCalculos(calculadora:ICalculador, num1, num2) {
45 | calculadora.sumar(num1,num2);
46 | calculadora.restar(num1,num2);
47 | calculadora.multiplicar(num1,num2);
48 | calculadora.dividir(num1,num2);
49 | return true;
50 | }
51 |
52 |
53 | // ademas del codigo anterior, estos pueden estar separados
54 |
55 | interface ICalculador extends ISumador {
56 | multiplicar(arg1:number, ...args:number[]):number;
57 | }
58 |
59 | interface ICalculador extends ISubstrator {
60 | dividir(arg1:number, ...args:number[]):number;
61 | }
62 |
63 | // tambien se puede crear una interface en el proceso de
64 | // declaracion mismo
65 |
66 | function addPoints(p1:IPoint, p2:IPoint):IPoint {
67 | var x = p1.x + p2.x;
68 | var y = p1.y + p2.y;
69 | return { x:x, y:y}
70 | }
71 |
72 | //Valido
73 | var newPoint = addPoints({x:3,y:4},{x:5,y:1});
74 | // Error
75 | //var newPoint = addPoints({x:1},{x:5,y:1});
76 |
77 | interface ITodo {
78 | titulo:string;
79 | texto:string
80 | }
81 |
82 | function hacerTarea(todo:ITodo){
83 | console.log(todo.titulo + " " + todo.texto);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/interfaces/todo.ts:
--------------------------------------------------------------------------------
1 | interface ITodo {
2 | title: string;
3 | text: string;
4 | }
5 |
6 | function showTodo(todo:ITodo) {
7 | console.log(todo.title + ':' + todo.text)
8 | }
9 |
10 | let todo:ITodo = {title:'task1', text:'my pending task'};
11 |
12 | showTodo(todo);
13 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-course",
3 | "version": "1.0.0",
4 | "description": "## Requirements - Optional: HTML, CSS, JS - Node.js and Npm - Console / Terminal Usage",
5 | "main": "dist/index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "clean:js": "rimraf ./**/**.js && rimraf dist",
9 | "serve": "http-server .",
10 | "build": "tsc",
11 | "watch": "tsc --watch",
12 | "dev": "ts-node-dev --respawn src/index.ts"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/FaztWeb/typescript-course.git"
17 | },
18 | "keywords": [],
19 | "author": "",
20 | "license": "ISC",
21 | "bugs": {
22 | "url": "https://github.com/FaztWeb/typescript-course/issues"
23 | },
24 | "homepage": "https://github.com/FaztWeb/typescript-course#readme",
25 | "dependencies": {
26 | "http-server": "^14.1.1",
27 | "rimraf": "^4.1.2"
28 | },
29 | "devDependencies": {
30 | "ts-node-dev": "^2.0.0",
31 | "tsun": "^0.5.1",
32 | "typescript": "^4.9.5"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 | lockfileVersion: 5.4
2 |
3 | specifiers:
4 | http-server: ^14.1.1
5 | rimraf: ^4.1.2
6 | ts-node-dev: ^2.0.0
7 | tsun: ^0.5.1
8 | typescript: ^4.9.5
9 |
10 | dependencies:
11 | http-server: 14.1.1
12 | rimraf: 4.1.2
13 |
14 | devDependencies:
15 | ts-node-dev: 2.0.0_typescript@4.9.5
16 | tsun: 0.5.1_typescript@4.9.5
17 | typescript: 4.9.5
18 |
19 | packages:
20 |
21 | /@cspotcode/source-map-support/0.8.1:
22 | resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
23 | engines: {node: '>=12'}
24 | dependencies:
25 | '@jridgewell/trace-mapping': 0.3.9
26 | dev: true
27 |
28 | /@jridgewell/resolve-uri/3.1.0:
29 | resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==}
30 | engines: {node: '>=6.0.0'}
31 | dev: true
32 |
33 | /@jridgewell/sourcemap-codec/1.4.14:
34 | resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==}
35 | dev: true
36 |
37 | /@jridgewell/trace-mapping/0.3.9:
38 | resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
39 | dependencies:
40 | '@jridgewell/resolve-uri': 3.1.0
41 | '@jridgewell/sourcemap-codec': 1.4.14
42 | dev: true
43 |
44 | /@tsconfig/node10/1.0.9:
45 | resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==}
46 | dev: true
47 |
48 | /@tsconfig/node12/1.0.11:
49 | resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
50 | dev: true
51 |
52 | /@tsconfig/node14/1.0.3:
53 | resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
54 | dev: true
55 |
56 | /@tsconfig/node16/1.0.3:
57 | resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==}
58 | dev: true
59 |
60 | /@types/node/6.14.13:
61 | resolution: {integrity: sha512-J1F0XJ/9zxlZel5ZlbeSuHW2OpabrUAqpFuC2sm2I3by8sERQ8+KCjNKUcq8QHuzpGMWiJpo9ZxeHrqrP2KzQw==}
62 | dev: true
63 |
64 | /@types/strip-bom/3.0.0:
65 | resolution: {integrity: sha512-xevGOReSYGM7g/kUBZzPqCrR/KYAo+F0yiPc85WFTJa0MSLtyFTVTU6cJu/aV4mid7IffDIWqo69THF2o4JiEQ==}
66 | dev: true
67 |
68 | /@types/strip-json-comments/0.0.30:
69 | resolution: {integrity: sha512-7NQmHra/JILCd1QqpSzl8+mJRc8ZHz3uDm8YV1Ks9IhK0epEiTw8aIErbvH9PI+6XbqhyIQy3462nEsn7UVzjQ==}
70 | dev: true
71 |
72 | /acorn-walk/8.2.0:
73 | resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==}
74 | engines: {node: '>=0.4.0'}
75 | dev: true
76 |
77 | /acorn/8.8.2:
78 | resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
79 | engines: {node: '>=0.4.0'}
80 | hasBin: true
81 | dev: true
82 |
83 | /ansi-regex/2.1.1:
84 | resolution: {integrity: sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==}
85 | engines: {node: '>=0.10.0'}
86 | dev: true
87 |
88 | /ansi-styles/2.2.1:
89 | resolution: {integrity: sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==}
90 | engines: {node: '>=0.10.0'}
91 | dev: true
92 |
93 | /ansi-styles/4.3.0:
94 | resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
95 | engines: {node: '>=8'}
96 | dependencies:
97 | color-convert: 2.0.1
98 | dev: false
99 |
100 | /ansi/0.3.1:
101 | resolution: {integrity: sha512-iFY7JCgHbepc0b82yLaw4IMortylNb6wG4kL+4R0C3iv6i+RHGHux/yUX5BTiRvSX/shMnngjR1YyNMnXEFh5A==}
102 | dev: true
103 |
104 | /anymatch/3.1.3:
105 | resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
106 | engines: {node: '>= 8'}
107 | dependencies:
108 | normalize-path: 3.0.0
109 | picomatch: 2.3.1
110 | dev: true
111 |
112 | /arg/4.1.3:
113 | resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
114 | dev: true
115 |
116 | /async/2.6.4:
117 | resolution: {integrity: sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==}
118 | dependencies:
119 | lodash: 4.17.21
120 | dev: false
121 |
122 | /balanced-match/1.0.2:
123 | resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
124 | dev: true
125 |
126 | /basic-auth/2.0.1:
127 | resolution: {integrity: sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==}
128 | engines: {node: '>= 0.8'}
129 | dependencies:
130 | safe-buffer: 5.1.2
131 | dev: false
132 |
133 | /binary-extensions/2.2.0:
134 | resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
135 | engines: {node: '>=8'}
136 | dev: true
137 |
138 | /brace-expansion/1.1.11:
139 | resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
140 | dependencies:
141 | balanced-match: 1.0.2
142 | concat-map: 0.0.1
143 | dev: true
144 |
145 | /braces/3.0.2:
146 | resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==}
147 | engines: {node: '>=8'}
148 | dependencies:
149 | fill-range: 7.0.1
150 | dev: true
151 |
152 | /buffer-from/1.1.2:
153 | resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
154 | dev: true
155 |
156 | /call-bind/1.0.2:
157 | resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==}
158 | dependencies:
159 | function-bind: 1.1.1
160 | get-intrinsic: 1.2.0
161 | dev: false
162 |
163 | /chalk/1.1.3:
164 | resolution: {integrity: sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==}
165 | engines: {node: '>=0.10.0'}
166 | dependencies:
167 | ansi-styles: 2.2.1
168 | escape-string-regexp: 1.0.5
169 | has-ansi: 2.0.0
170 | strip-ansi: 3.0.1
171 | supports-color: 2.0.0
172 | dev: true
173 |
174 | /chalk/4.1.2:
175 | resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
176 | engines: {node: '>=10'}
177 | dependencies:
178 | ansi-styles: 4.3.0
179 | supports-color: 7.2.0
180 | dev: false
181 |
182 | /chokidar/3.5.3:
183 | resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==}
184 | engines: {node: '>= 8.10.0'}
185 | dependencies:
186 | anymatch: 3.1.3
187 | braces: 3.0.2
188 | glob-parent: 5.1.2
189 | is-binary-path: 2.1.0
190 | is-glob: 4.0.3
191 | normalize-path: 3.0.0
192 | readdirp: 3.6.0
193 | optionalDependencies:
194 | fsevents: 2.3.2
195 | dev: true
196 |
197 | /color-convert/2.0.1:
198 | resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
199 | engines: {node: '>=7.0.0'}
200 | dependencies:
201 | color-name: 1.1.4
202 | dev: false
203 |
204 | /color-name/1.1.4:
205 | resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
206 | dev: false
207 |
208 | /colors/1.4.0:
209 | resolution: {integrity: sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==}
210 | engines: {node: '>=0.1.90'}
211 | dev: true
212 |
213 | /concat-map/0.0.1:
214 | resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
215 | dev: true
216 |
217 | /corser/2.0.1:
218 | resolution: {integrity: sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==}
219 | engines: {node: '>= 0.4.0'}
220 | dev: false
221 |
222 | /create-require/1.1.1:
223 | resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
224 | dev: true
225 |
226 | /debug/3.2.7:
227 | resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
228 | peerDependencies:
229 | supports-color: '*'
230 | peerDependenciesMeta:
231 | supports-color:
232 | optional: true
233 | dependencies:
234 | ms: 2.1.3
235 | dev: false
236 |
237 | /diff/3.5.0:
238 | resolution: {integrity: sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==}
239 | engines: {node: '>=0.3.1'}
240 | dev: true
241 |
242 | /diff/4.0.2:
243 | resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
244 | engines: {node: '>=0.3.1'}
245 | dev: true
246 |
247 | /dynamic-dedupe/0.3.0:
248 | resolution: {integrity: sha512-ssuANeD+z97meYOqd50e04Ze5qp4bPqo8cCkI4TRjZkzAUgIDTrXV1R8QCdINpiI+hw14+rYazvTRdQrz0/rFQ==}
249 | dependencies:
250 | xtend: 4.0.2
251 | dev: true
252 |
253 | /escape-string-regexp/1.0.5:
254 | resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==}
255 | engines: {node: '>=0.8.0'}
256 | dev: true
257 |
258 | /eventemitter3/4.0.7:
259 | resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
260 | dev: false
261 |
262 | /fill-range/7.0.1:
263 | resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
264 | engines: {node: '>=8'}
265 | dependencies:
266 | to-regex-range: 5.0.1
267 | dev: true
268 |
269 | /follow-redirects/1.15.2:
270 | resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
271 | engines: {node: '>=4.0'}
272 | peerDependencies:
273 | debug: '*'
274 | peerDependenciesMeta:
275 | debug:
276 | optional: true
277 | dev: false
278 |
279 | /fs.realpath/1.0.0:
280 | resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
281 | dev: true
282 |
283 | /fsevents/2.3.2:
284 | resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
285 | engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
286 | os: [darwin]
287 | requiresBuild: true
288 | dev: true
289 | optional: true
290 |
291 | /function-bind/1.1.1:
292 | resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==}
293 |
294 | /get-intrinsic/1.2.0:
295 | resolution: {integrity: sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==}
296 | dependencies:
297 | function-bind: 1.1.1
298 | has: 1.0.3
299 | has-symbols: 1.0.3
300 | dev: false
301 |
302 | /glob-parent/5.1.2:
303 | resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
304 | engines: {node: '>= 6'}
305 | dependencies:
306 | is-glob: 4.0.3
307 | dev: true
308 |
309 | /glob/7.2.3:
310 | resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
311 | dependencies:
312 | fs.realpath: 1.0.0
313 | inflight: 1.0.6
314 | inherits: 2.0.4
315 | minimatch: 3.1.2
316 | once: 1.4.0
317 | path-is-absolute: 1.0.1
318 | dev: true
319 |
320 | /has-ansi/2.0.0:
321 | resolution: {integrity: sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==}
322 | engines: {node: '>=0.10.0'}
323 | dependencies:
324 | ansi-regex: 2.1.1
325 | dev: true
326 |
327 | /has-flag/4.0.0:
328 | resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
329 | engines: {node: '>=8'}
330 | dev: false
331 |
332 | /has-symbols/1.0.3:
333 | resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
334 | engines: {node: '>= 0.4'}
335 | dev: false
336 |
337 | /has/1.0.3:
338 | resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==}
339 | engines: {node: '>= 0.4.0'}
340 | dependencies:
341 | function-bind: 1.1.1
342 |
343 | /he/1.2.0:
344 | resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
345 | hasBin: true
346 | dev: false
347 |
348 | /html-encoding-sniffer/3.0.0:
349 | resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==}
350 | engines: {node: '>=12'}
351 | dependencies:
352 | whatwg-encoding: 2.0.0
353 | dev: false
354 |
355 | /http-proxy/1.18.1:
356 | resolution: {integrity: sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==}
357 | engines: {node: '>=8.0.0'}
358 | dependencies:
359 | eventemitter3: 4.0.7
360 | follow-redirects: 1.15.2
361 | requires-port: 1.0.0
362 | transitivePeerDependencies:
363 | - debug
364 | dev: false
365 |
366 | /http-server/14.1.1:
367 | resolution: {integrity: sha512-+cbxadF40UXd9T01zUHgA+rlo2Bg1Srer4+B4NwIHdaGxAGGv59nYRnGGDJ9LBk7alpS0US+J+bLLdQOOkJq4A==}
368 | engines: {node: '>=12'}
369 | hasBin: true
370 | dependencies:
371 | basic-auth: 2.0.1
372 | chalk: 4.1.2
373 | corser: 2.0.1
374 | he: 1.2.0
375 | html-encoding-sniffer: 3.0.0
376 | http-proxy: 1.18.1
377 | mime: 1.6.0
378 | minimist: 1.2.7
379 | opener: 1.5.2
380 | portfinder: 1.0.32
381 | secure-compare: 3.0.1
382 | union: 0.5.0
383 | url-join: 4.0.1
384 | transitivePeerDependencies:
385 | - debug
386 | - supports-color
387 | dev: false
388 |
389 | /iconv-lite/0.6.3:
390 | resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
391 | engines: {node: '>=0.10.0'}
392 | dependencies:
393 | safer-buffer: 2.1.2
394 | dev: false
395 |
396 | /inflight/1.0.6:
397 | resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
398 | dependencies:
399 | once: 1.4.0
400 | wrappy: 1.0.2
401 | dev: true
402 |
403 | /inherits/2.0.4:
404 | resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
405 | dev: true
406 |
407 | /is-binary-path/2.1.0:
408 | resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
409 | engines: {node: '>=8'}
410 | dependencies:
411 | binary-extensions: 2.2.0
412 | dev: true
413 |
414 | /is-core-module/2.11.0:
415 | resolution: {integrity: sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==}
416 | dependencies:
417 | has: 1.0.3
418 | dev: true
419 |
420 | /is-extglob/2.1.1:
421 | resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
422 | engines: {node: '>=0.10.0'}
423 | dev: true
424 |
425 | /is-glob/4.0.3:
426 | resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==}
427 | engines: {node: '>=0.10.0'}
428 | dependencies:
429 | is-extglob: 2.1.1
430 | dev: true
431 |
432 | /is-number/7.0.0:
433 | resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
434 | engines: {node: '>=0.12.0'}
435 | dev: true
436 |
437 | /lodash/4.17.21:
438 | resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
439 | dev: false
440 |
441 | /make-error/1.3.6:
442 | resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
443 | dev: true
444 |
445 | /mime/1.6.0:
446 | resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==}
447 | engines: {node: '>=4'}
448 | hasBin: true
449 | dev: false
450 |
451 | /minimatch/3.1.2:
452 | resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
453 | dependencies:
454 | brace-expansion: 1.1.11
455 | dev: true
456 |
457 | /minimist/0.0.10:
458 | resolution: {integrity: sha512-iotkTvxc+TwOm5Ieim8VnSNvCDjCK9S8G3scJ50ZthspSxa7jx50jkhYduuAtAjvfDUwSgOwf8+If99AlOEhyw==}
459 | dev: true
460 |
461 | /minimist/1.2.7:
462 | resolution: {integrity: sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==}
463 |
464 | /mkdirp/0.5.6:
465 | resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
466 | hasBin: true
467 | dependencies:
468 | minimist: 1.2.7
469 | dev: false
470 |
471 | /mkdirp/1.0.4:
472 | resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==}
473 | engines: {node: '>=10'}
474 | hasBin: true
475 | dev: true
476 |
477 | /ms/2.1.3:
478 | resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
479 | dev: false
480 |
481 | /node-color-readline/1.0.1:
482 | resolution: {integrity: sha512-h66cRVEWnPQFxh5Y1hk9MNs6jvlB26CjT727ZztkIkPN+eyRI2c9powQrBJ9pty2Kj7IBySDnYHig7QElmU4Pg==}
483 | dependencies:
484 | ansi: 0.3.1
485 | chalk: 1.1.3
486 | dev: true
487 |
488 | /normalize-path/3.0.0:
489 | resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
490 | engines: {node: '>=0.10.0'}
491 | dev: true
492 |
493 | /object-inspect/1.12.3:
494 | resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==}
495 | dev: false
496 |
497 | /once/1.4.0:
498 | resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
499 | dependencies:
500 | wrappy: 1.0.2
501 | dev: true
502 |
503 | /opener/1.5.2:
504 | resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==}
505 | hasBin: true
506 | dev: false
507 |
508 | /optimist/0.6.1:
509 | resolution: {integrity: sha512-snN4O4TkigujZphWLN0E//nQmm7790RYaE53DdL7ZYwee2D8DDo9/EyYiKUfN3rneWUjhJnueija3G9I2i0h3g==}
510 | dependencies:
511 | minimist: 0.0.10
512 | wordwrap: 0.0.3
513 | dev: true
514 |
515 | /path-is-absolute/1.0.1:
516 | resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==}
517 | engines: {node: '>=0.10.0'}
518 | dev: true
519 |
520 | /path-parse/1.0.7:
521 | resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
522 | dev: true
523 |
524 | /picomatch/2.3.1:
525 | resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
526 | engines: {node: '>=8.6'}
527 | dev: true
528 |
529 | /portfinder/1.0.32:
530 | resolution: {integrity: sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==}
531 | engines: {node: '>= 0.12.0'}
532 | dependencies:
533 | async: 2.6.4
534 | debug: 3.2.7
535 | mkdirp: 0.5.6
536 | transitivePeerDependencies:
537 | - supports-color
538 | dev: false
539 |
540 | /qs/6.11.0:
541 | resolution: {integrity: sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==}
542 | engines: {node: '>=0.6'}
543 | dependencies:
544 | side-channel: 1.0.4
545 | dev: false
546 |
547 | /readdirp/3.6.0:
548 | resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
549 | engines: {node: '>=8.10.0'}
550 | dependencies:
551 | picomatch: 2.3.1
552 | dev: true
553 |
554 | /requires-port/1.0.0:
555 | resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==}
556 | dev: false
557 |
558 | /resolve/1.22.1:
559 | resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==}
560 | hasBin: true
561 | dependencies:
562 | is-core-module: 2.11.0
563 | path-parse: 1.0.7
564 | supports-preserve-symlinks-flag: 1.0.0
565 | dev: true
566 |
567 | /rimraf/2.6.3:
568 | resolution: {integrity: sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==}
569 | hasBin: true
570 | dependencies:
571 | glob: 7.2.3
572 | dev: true
573 |
574 | /rimraf/2.7.1:
575 | resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==}
576 | hasBin: true
577 | dependencies:
578 | glob: 7.2.3
579 | dev: true
580 |
581 | /rimraf/4.1.2:
582 | resolution: {integrity: sha512-BlIbgFryTbw3Dz6hyoWFhKk+unCcHMSkZGrTFVAx2WmttdBSonsdtRlwiuTbDqTKr+UlXIUqJVS4QT5tUzGENQ==}
583 | engines: {node: '>=14'}
584 | hasBin: true
585 | dev: false
586 |
587 | /safe-buffer/5.1.2:
588 | resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
589 | dev: false
590 |
591 | /safer-buffer/2.1.2:
592 | resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==}
593 | dev: false
594 |
595 | /secure-compare/3.0.1:
596 | resolution: {integrity: sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==}
597 | dev: false
598 |
599 | /side-channel/1.0.4:
600 | resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==}
601 | dependencies:
602 | call-bind: 1.0.2
603 | get-intrinsic: 1.2.0
604 | object-inspect: 1.12.3
605 | dev: false
606 |
607 | /source-map-support/0.5.21:
608 | resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
609 | dependencies:
610 | buffer-from: 1.1.2
611 | source-map: 0.6.1
612 | dev: true
613 |
614 | /source-map/0.6.1:
615 | resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
616 | engines: {node: '>=0.10.0'}
617 | dev: true
618 |
619 | /strip-ansi/3.0.1:
620 | resolution: {integrity: sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==}
621 | engines: {node: '>=0.10.0'}
622 | dependencies:
623 | ansi-regex: 2.1.1
624 | dev: true
625 |
626 | /strip-bom/3.0.0:
627 | resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==}
628 | engines: {node: '>=4'}
629 | dev: true
630 |
631 | /strip-json-comments/2.0.1:
632 | resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
633 | engines: {node: '>=0.10.0'}
634 | dev: true
635 |
636 | /supports-color/2.0.0:
637 | resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}
638 | engines: {node: '>=0.8.0'}
639 | dev: true
640 |
641 | /supports-color/7.2.0:
642 | resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
643 | engines: {node: '>=8'}
644 | dependencies:
645 | has-flag: 4.0.0
646 | dev: false
647 |
648 | /supports-preserve-symlinks-flag/1.0.0:
649 | resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
650 | engines: {node: '>= 0.4'}
651 | dev: true
652 |
653 | /temp/0.8.4:
654 | resolution: {integrity: sha512-s0ZZzd0BzYv5tLSptZooSjK8oj6C+c19p7Vqta9+6NPOf7r+fxq0cJe6/oN4LTC79sy5NY8ucOJNgwsKCSbfqg==}
655 | engines: {node: '>=6.0.0'}
656 | dependencies:
657 | rimraf: 2.6.3
658 | dev: true
659 |
660 | /to-regex-range/5.0.1:
661 | resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
662 | engines: {node: '>=8.0'}
663 | dependencies:
664 | is-number: 7.0.0
665 | dev: true
666 |
667 | /tree-kill/1.2.2:
668 | resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
669 | hasBin: true
670 | dev: true
671 |
672 | /ts-node-dev/2.0.0_typescript@4.9.5:
673 | resolution: {integrity: sha512-ywMrhCfH6M75yftYvrvNarLEY+SUXtUvU8/0Z6llrHQVBx12GiFk5sStF8UdfE/yfzk9IAq7O5EEbTQsxlBI8w==}
674 | engines: {node: '>=0.8.0'}
675 | hasBin: true
676 | peerDependencies:
677 | node-notifier: '*'
678 | typescript: '*'
679 | peerDependenciesMeta:
680 | node-notifier:
681 | optional: true
682 | dependencies:
683 | chokidar: 3.5.3
684 | dynamic-dedupe: 0.3.0
685 | minimist: 1.2.7
686 | mkdirp: 1.0.4
687 | resolve: 1.22.1
688 | rimraf: 2.7.1
689 | source-map-support: 0.5.21
690 | tree-kill: 1.2.2
691 | ts-node: 10.9.1_typescript@4.9.5
692 | tsconfig: 7.0.0
693 | typescript: 4.9.5
694 | transitivePeerDependencies:
695 | - '@swc/core'
696 | - '@swc/wasm'
697 | - '@types/node'
698 | dev: true
699 |
700 | /ts-node/10.9.1_typescript@4.9.5:
701 | resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
702 | hasBin: true
703 | peerDependencies:
704 | '@swc/core': '>=1.2.50'
705 | '@swc/wasm': '>=1.2.50'
706 | '@types/node': '*'
707 | typescript: '>=2.7'
708 | peerDependenciesMeta:
709 | '@swc/core':
710 | optional: true
711 | '@swc/wasm':
712 | optional: true
713 | dependencies:
714 | '@cspotcode/source-map-support': 0.8.1
715 | '@tsconfig/node10': 1.0.9
716 | '@tsconfig/node12': 1.0.11
717 | '@tsconfig/node14': 1.0.3
718 | '@tsconfig/node16': 1.0.3
719 | acorn: 8.8.2
720 | acorn-walk: 8.2.0
721 | arg: 4.1.3
722 | create-require: 1.1.1
723 | diff: 4.0.2
724 | make-error: 1.3.6
725 | typescript: 4.9.5
726 | v8-compile-cache-lib: 3.0.1
727 | yn: 3.1.1
728 | dev: true
729 |
730 | /tsconfig/7.0.0:
731 | resolution: {integrity: sha512-vZXmzPrL+EmC4T/4rVlT2jNVMWCi/O4DIiSj3UHg1OE5kCKbk4mfrXc6dZksLgRM/TZlKnousKH9bbTazUWRRw==}
732 | dependencies:
733 | '@types/strip-bom': 3.0.0
734 | '@types/strip-json-comments': 0.0.30
735 | strip-bom: 3.0.0
736 | strip-json-comments: 2.0.1
737 | dev: true
738 |
739 | /tslib/1.14.1:
740 | resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
741 | dev: true
742 |
743 | /tsun/0.5.1_typescript@4.9.5:
744 | resolution: {integrity: sha512-AK60MDwV2lbafn6bt6sV8dw8UjnWh3yo6bUp9rEGRm4ExbyaZQxN3fnsl3VAtug3/DYXw2Gxp6NQpIpev63koA==}
745 | hasBin: true
746 | peerDependencies:
747 | typescript: '>=3.0.0'
748 | dependencies:
749 | '@types/node': 6.14.13
750 | colors: 1.4.0
751 | diff: 3.5.0
752 | node-color-readline: 1.0.1
753 | optimist: 0.6.1
754 | temp: 0.8.4
755 | tslib: 1.14.1
756 | typescript: 4.9.5
757 | dev: true
758 |
759 | /typescript/4.9.5:
760 | resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
761 | engines: {node: '>=4.2.0'}
762 | hasBin: true
763 | dev: true
764 |
765 | /union/0.5.0:
766 | resolution: {integrity: sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==}
767 | engines: {node: '>= 0.8.0'}
768 | dependencies:
769 | qs: 6.11.0
770 | dev: false
771 |
772 | /url-join/4.0.1:
773 | resolution: {integrity: sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==}
774 | dev: false
775 |
776 | /v8-compile-cache-lib/3.0.1:
777 | resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
778 | dev: true
779 |
780 | /whatwg-encoding/2.0.0:
781 | resolution: {integrity: sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==}
782 | engines: {node: '>=12'}
783 | dependencies:
784 | iconv-lite: 0.6.3
785 | dev: false
786 |
787 | /wordwrap/0.0.3:
788 | resolution: {integrity: sha512-1tMA907+V4QmxV7dbRvb4/8MaRALK6q9Abid3ndMYnbyo8piisCmeONVqVSXqQA3KaP4SLt5b7ud6E2sqP8TFw==}
789 | engines: {node: '>=0.4.0'}
790 | dev: true
791 |
792 | /wrappy/1.0.2:
793 | resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
794 | dev: true
795 |
796 | /xtend/4.0.2:
797 | resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
798 | engines: {node: '>=0.4'}
799 | dev: true
800 |
801 | /yn/3.1.1:
802 | resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
803 | engines: {node: '>=6'}
804 | dev: true
805 |
--------------------------------------------------------------------------------
/practice/jquery/example1.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | // declare var $:any;
4 |
5 | //
6 |
7 | module Fazt.FirstModule {
8 | export class Handler {
9 | static DisplayDate(): void {
10 | var currentDate:Date = new Date();
11 | $('#txtDemo').text(currentDate.toUTCString());
12 | }
13 | }
14 | }
15 |
16 | $('#btnGo').click(Fazt.FirstModule.Handler.DisplayDate);
--------------------------------------------------------------------------------
/practice/jquery/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | this is a paragraph
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/practice/jquery/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "examples",
3 | "version": "1.0.0",
4 | "description": "",
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 | "@types/jquery": "^2.0.43"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/practice/types_browser/app.ts:
--------------------------------------------------------------------------------
1 | let myNickname: string = 'Fazt';
2 |
3 | let myAge: number = 80;
4 |
5 | let canVote: boolean = true;
6 |
7 | let anything: any = 'dog';
8 | anything = 2;
9 |
10 | document.getElementById('output')
11 | .innerHTML = `My Name is ${myNickname}`;
12 |
13 | document.write(`canVote is a ${typeof(canVote)}
`);
14 | document.write(`my nikname is a ${typeof(myNickname)}
`);
15 | document.write(`anything have the type ${typeof(anything)}
`);
16 |
--------------------------------------------------------------------------------
/practice/types_browser/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Practicing Typescript on the Browser
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/basics/datatypes.ts:
--------------------------------------------------------------------------------
1 | const myName: string = "Aaron"; // strings
2 | const height: number = 1.78; // numbers: floting point numbers
3 | let lastExam: null = null;
4 | let isDone: boolean = true; // boolean
5 | isDone = false;
6 | let lastNote: undefined = undefined;
7 | let someValue; // any
8 |
--------------------------------------------------------------------------------
/src/basics/dynamic_static.ts:
--------------------------------------------------------------------------------
1 | let a = 10;
2 | let b = "20";
3 |
4 | console.log(a + b); // 1020
5 | // console.log(a - b); // -10, Error
--------------------------------------------------------------------------------
/src/basics/type_interence.ts:
--------------------------------------------------------------------------------
1 | // let nickname = "fazt"; // typescript infers that nickname is a string
2 |
3 | // nickname = 100; // Error
4 |
5 | // let nickname: string;
6 | // nickname = 100;
7 |
8 | // regex to select all words
9 | const regex = /\w+/g; // type RegExp
--------------------------------------------------------------------------------
/src/basics/union_types.ts:
--------------------------------------------------------------------------------
1 | let digit: string | number;
2 | let code: string | number | boolean;
3 |
4 | digit = "seven";
5 | digit = 7;
6 |
7 | console.log(digit);
8 |
9 | let path: string[] | string;
10 | path = "/temp/log.xml";
11 | path = ["/temp/log.xml", "/temp/errors.xml"];
12 | // path = 1; // Error
13 |
14 | let fruit: "🥝" | "🍌" | "🍎" = "🍌";
15 | console.log(fruit);
16 |
17 | fruit = "🍎";
18 |
--------------------------------------------------------------------------------
/src/classes/Person.ts:
--------------------------------------------------------------------------------
1 | class Person {
2 | firstName: string | undefined;
3 | lastName: string | undefined;
4 | age: number;
5 |
6 | constructor(name?: string, lastName?: string, age: number = 0) {
7 | this.firstName = name;
8 | this.lastName = lastName;
9 | this.age = age;
10 | }
11 |
12 | greet(friend: string): string {
13 | return "Hello " + friend + ", My name is " + this.firstName;
14 | }
15 | }
16 |
17 | let maria: Person = new Person();
18 | maria.firstName = "Maria";
19 | maria.lastName = "Levasca";
20 | maria.age = 25;
21 |
22 | let isaac: Person = new Person();
23 | isaac.firstName = "Isaac";
24 | isaac.lastName = "Delahaye";
25 |
26 | maria.greet(isaac.firstName);
27 |
--------------------------------------------------------------------------------
/src/classes/Point.ts:
--------------------------------------------------------------------------------
1 | class Point {
2 | public x:number;
3 | public y:number;
4 | constructor(x:number,y = 0){
5 | this.x = x;
6 | this.y = y;
7 | }
8 | }
--------------------------------------------------------------------------------
/src/classes/User.ts:
--------------------------------------------------------------------------------
1 | interface IUser {
2 | name: string;
3 | email: string;
4 | age: number;
5 | register(): void;
6 | payMembership(): void;
7 | }
8 |
9 | class User implements IUser {
10 | name: string;
11 | email: string;
12 | age: number;
13 |
14 | constructor(name: string, email: string, age: number) {
15 | this.name = name;
16 | this.email = email;
17 | this.age = age;
18 |
19 | console.log("User created: ", this.name);
20 | }
21 |
22 | register() {
23 | console.log(this.name + "is now regitered");
24 | }
25 |
26 | payMembership() {
27 | console.log(this.name + "paid membership");
28 | }
29 | }
30 |
31 | // inheritance
32 |
33 | class Member extends User {
34 | id: number;
35 | constructor(id: number, name: string, email: string, age: number) {
36 | super(name, email, age);
37 | this.id = id;
38 | }
39 |
40 | payMembership() {
41 | super.payMembership();
42 | }
43 | }
44 |
45 | let isaacNewton = new User("isaac Newton", "isaacNewton@gmail.com", 34);
46 |
47 | console.log(isaacNewton.age);
48 | isaacNewton.register();
49 |
50 | let mike = new Member(1, "Mike Portnoy", "mike@email.com", 50);
51 | mike.payMembership();
52 |
--------------------------------------------------------------------------------
/src/classes/class_interfaces.ts:
--------------------------------------------------------------------------------
1 | interface ITransport {
2 | name: string;
3 | speed: number;
4 | move: () => string
5 | }
6 |
7 | class Transport implements ITransport {
8 | constructor(public name: string, public speed: number) {}
9 |
10 | move() {
11 | return `${this.name} is moving at ${this.speed} km/h`;
12 | }
13 | }
14 |
15 | const car = new Transport("Car", 100);
16 | console.log(car.move());
17 |
--------------------------------------------------------------------------------
/src/classes/constructor.ts:
--------------------------------------------------------------------------------
1 | class Computer {
2 | private id: number;
3 |
4 | constructor(public brand: string, public price: number) {
5 | this.id = Math.random();
6 | }
7 |
8 | // This is a method
9 | showInfo() {
10 | console.log(`${this.id}, ${this.brand} costs ${this.price}`);
11 | }
12 | }
13 |
14 | const laptop1 = new Computer("Mac", 1000);
15 | const laptop2 = new Computer("Lenovo", 2000);
16 |
17 | console.log(laptop1);
18 | console.log(laptop2);
19 |
--------------------------------------------------------------------------------
/src/classes/inheritance.ts:
--------------------------------------------------------------------------------
1 | // class receive behaivour of parent class
2 |
3 | class Report {
4 | data: Array;
5 |
6 | constructor(data:Array) {
7 | this.data = data;
8 | }
9 |
10 | run() {
11 | this.data.forEach((line) => {
12 | console.log(line)
13 | });
14 | }
15 | }
16 |
17 | var report:Report = new Report(['first line', 'second line']);
18 | report.run();
19 |
20 | class TabbedReport extends Report {
21 |
22 | headers: Array;
23 |
24 | constructor(headers: string[], values: string[]) {
25 | super(values);
26 | this.headers = headers;
27 | }
28 |
29 | run() {
30 | console.log(this.headers);
31 | super.run();
32 | }
33 | }
34 |
35 | var headers: string[] = ['Name'];
36 | var data: string[] = ['Alice Green', 'Isaac Asimov', 'Isaac Delahaye'];
37 | var r: TabbedReport = new TabbedReport(headers, data);
38 | r.run();
39 |
40 |
41 | // Second Example of inheritance
42 |
43 | class CommonPerson {
44 | constructor(public name: string, public lastname: string) {}
45 | }
46 |
47 | const joe = new CommonPerson("Joe", "Smith");
48 | console.log(joe);
49 |
50 | // Subclass
51 | class Programmer extends CommonPerson {
52 | constructor(firstname: string, lastname: string, public language: string) {
53 | super(firstname, lastname);
54 | }
55 | }
56 |
57 | const ryan = new Programmer("Ryan", "Ray", "JavaScript");
58 | console.log(ryan);
--------------------------------------------------------------------------------
/src/classes/methods.ts:
--------------------------------------------------------------------------------
1 | class MyMath {
2 | constructor() {}
3 |
4 | add(x: number, y: number) {
5 | return x + y;
6 | }
7 |
8 | subtract(x: number, y: number) {
9 | return x - y;
10 | }
11 | }
12 |
13 | const math = new MyMath();
14 | console.log(math.add(1, 2));
15 | console.log(math.subtract(1, 2));
16 |
--------------------------------------------------------------------------------
/src/classes/pending_example.ts:
--------------------------------------------------------------------------------
1 | interface IPoint {
2 | x: number;
3 | y: number;
4 | }
5 |
6 | // Some other example of interface
7 | function addPoints(this: any, p1: IPoint, p2: IPoint): IPoint {
8 | this.x = p1.x + p2.x;
9 | this.y = p1.y + p2.y;
10 | return { x: this.x, y: this.y };
11 | }
12 | // valid
13 | var pointOne = addPoints({ x: 1, y: 1 }, { x: 4, y: 4 });
14 |
--------------------------------------------------------------------------------
/src/functions/index.ts:
--------------------------------------------------------------------------------
1 | // Basic function
2 | function print(message: string) {
3 | console.log(message);
4 | }
5 | print("Hello world");
6 |
7 | // Function with types
8 | function print2(message: string): void {
9 | console.log(message);
10 | }
11 | print2("Hello world");
12 |
13 | // Return type
14 | function greets(name: string): string {
15 | return `Hello + ${name}`;
16 | }
17 | console.log(greetMe("Juan"));
18 |
19 | function add(x: number, y: number): number {
20 | return x + y;
21 | }
22 |
23 | const add2 = (x: number, y: number): number => x + y;
24 |
25 | // union types in parameters
26 | function countChars(message: string | number): void {
27 | console.log(message.toString().length);
28 | }
29 |
30 | countChars(200);
31 | countChars("hello");
32 |
33 | // array as parameter
34 | const squares = (array: number[]) => array.map((x) => x * x);
35 | const resultSquares = squares([10, 3, 4]);
36 | console.log(resultSquares);
37 |
38 | function myVoid(): void {
39 | return;
40 | }
41 |
42 | // function annotation with parameter
43 | // type annotation and return type annotation
44 | let sayHello: (name: string) => string;
45 |
46 | // implementation
47 | sayHello = (name: string) => {
48 | return "Hello" + name;
49 | };
50 |
51 | //optional parameter
52 | // when is not parameter, ts assign null value to it
53 | function addThree(x: number, y: number, z?: number): number {
54 | if (z !== undefined) {
55 | return x + y + z;
56 | }
57 | return x + y;
58 | }
59 |
60 | function greetMe(name: string, greeting?: string): string {
61 | if (!greeting) {
62 | greeting = "Hello";
63 | }
64 | return greeting + ", " + name;
65 | }
66 |
67 | // default parameter
68 | function greetMeRefactored(name: string, greeting: string = "Hello"): string {
69 | return greeting + ", " + name;
70 | }
71 |
72 | // overloads
73 | // we can use the add strings and numbers
74 | function polimorphicAdd(x: string, y: string): string;
75 | function polimorphicAdd(x: number, y: number): number;
76 | function polimorphicAdd(x: any, y: any): any {
77 | return x + y;
78 | }
79 |
80 | console.log(polimorphicAdd(10, 20));
81 | console.log(polimorphicAdd("hello", "world"));
82 | // console.log(polimorphicAdd("hello", 20)); // errro
83 |
84 | // to operate unlimited parameters
85 | function showNames(...names: string[]) {
86 | for (var i = 0; i < names.length; i++) {
87 | console.log(names[i]);
88 | }
89 | }
90 | showNames("Ryan");
91 | showNames("Juan", "Pedro", "Maria");
92 |
93 | // a rest parameter can only be the final param in a function
94 | function addMultiples(arg1: string, ...args: string[]): string;
95 | function addMultiples(arg1: number, ...args: number[]): number;
96 | function addMultiples(arg1: any, ...args: any[]): any {
97 | var total = arg1;
98 | for (var i = 0; i < args.length; i++) {
99 | total += args[i];
100 | }
101 | return total;
102 | }
103 |
104 | console.log(10);
105 | console.log(addMultiples(1, 2, 3, 4, 5));
106 | console.log(addMultiples(10, 20, 30, 40, 50));
107 | console.log(addMultiples("jesus", "roberto", "juan", "pedro"));
108 |
109 | // ademas podemos crear un arreglo que represente nuestra lista indeterminada de parametros
110 |
111 | function sumaCuantosQuieras(arg1: any) {
112 | var args = [];
113 | for (var _i = 0; _i < arguments.length - 1; _i++) {
114 | args[_i] = arguments[_i + 1];
115 | }
116 |
117 | var total = arg1;
118 | for (var i = 0; i < args.length; i++) {
119 | total += args[i];
120 | }
121 |
122 | return total;
123 | }
124 |
--------------------------------------------------------------------------------
/src/generics.ts:
--------------------------------------------------------------------------------
1 | function getLast(arr: T[]): T {
2 | return arr[arr.length - 1]
3 | }
4 |
5 | const result = getLast([1, 2, 3])
6 | const result2 = getLast(['a', 'b', 'c'])
7 | console.log(result)
8 | console.log(result2)
--------------------------------------------------------------------------------
/src/helloworld/helloworld.ts:
--------------------------------------------------------------------------------
1 | // console.log('hello world')
2 |
3 | let hello: string = "Hello world"
4 | // hello = 300; //error
5 |
6 | console.log(hello)
7 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import './generics'
2 |
--------------------------------------------------------------------------------
/src/interfaces/index.ts:
--------------------------------------------------------------------------------
1 | // Basic interface
2 | interface IProduct {
3 | name: string;
4 | readonly price: number; // readonly is a modifier
5 | description?: string;
6 | }
7 |
8 | const product: IProduct = {
9 | name: "laptop",
10 | price: 1000,
11 | description: "good laptop",
12 | };
13 |
14 | // product.price = 2000; // error
15 |
16 | // Interfaces with Functions
17 | interface MathFunction {
18 | (a: number, b: number): number;
19 | }
20 |
21 | const sum: MathFunction = (a, b) => a + b;
22 | const subtract: MathFunction = (a, b) => a - b;
23 | const multply: MathFunction = (a, b) => a * b;
24 | const divide: MathFunction = (a, b) => a / b;
25 |
26 | const mod: MathFunction = (a: number, b: number) => a % b;
27 |
28 | console.log(sum(10, 20));
29 | console.log(subtract(10, 20));
30 | console.log(multply(10, 20));
31 | console.log(divide(10, 20));
--------------------------------------------------------------------------------
/src/types/ambient_declarations.ts:
--------------------------------------------------------------------------------
1 | // declara a variable that is not converted to JS
--------------------------------------------------------------------------------
/src/types/block_scope.ts:
--------------------------------------------------------------------------------
1 | for (var i = 0; i < 10; i++) {
2 | console.log(i);
3 | }
4 |
5 | console.log("....");
6 |
7 | var i: number; // 10
8 | console.log(i);
9 |
10 | //keywords:
11 | // 'var' are scoped to the nearest function block
12 | // or global if outside a function block
13 | var mynum: number = 1;
14 |
15 | // 'let' are scoped to the nearest enclosing block
16 | // or global if outside any block
17 | let isValid: boolean = true;
18 |
19 | // create a constant that is block scoped
20 | const apiKey: string = "05311212";
21 |
--------------------------------------------------------------------------------
/src/types/type_aliases.ts:
--------------------------------------------------------------------------------
1 | // Type aliases are exactly the same as their original types
2 | type PrimitiveArray = Array;
3 | type MyNumber = number;
4 | //type NgScope = ng.IScope;
5 | type Callback = () => void;
6 |
7 | // to check the type of data
8 | // typeof myName;
--------------------------------------------------------------------------------
/src/types/type_guards.ts:
--------------------------------------------------------------------------------
1 | var x: any = { /**/ };
2 |
3 | if(typeof x === 'string') {
4 | // now ts assume x is a string, this feature is know as
5 | // type guard
6 | //console.log(x.splice(3, 1)); // splice doesn' exist on a string
7 | console.log(x.length);
8 | }
9 | //x is still any
10 | x.foo(); //ok
11 |
12 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */
4 |
5 | /* Projects */
6 | // "incremental": true, /* Enable incremental compilation */
7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8 | // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12 |
13 | /* Language and Environment */
14 | "target": "ES2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16 | // "jsx": "preserve", /* Specify what JSX code is generated. */
17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22 | // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25 |
26 | /* Modules */
27 | "module": "commonjs", /* Specify what module code is generated. */
28 | // "rootDir": "./src", /* Specify the root folder within your source files. */
29 | // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33 | "typeRoots": [
34 | "./src/@types"
35 | ], /* Specify multiple folders that act like `./node_modules/@types`. */
36 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38 | // "resolveJsonModule": true, /* Enable importing .json files */
39 | // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */
40 |
41 | /* JavaScript Support */
42 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
43 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
45 |
46 | /* Emit */
47 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
52 | "outDir": "./dist", /* Specify an output folder for all emitted files. */
53 | // "removeComments": true, /* Disable emitting comments. */
54 | // "noEmit": true, /* Disable emitting files from a compilation. */
55 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
57 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63 | // "newLine": "crlf", /* Set the newline character for emitting files. */
64 | // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
65 | // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
66 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67 | // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
68 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70 |
71 | /* Interop Constraints */
72 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
75 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77 |
78 | /* Type Checking */
79 | "strict": true, /* Enable all strict type-checking options. */
80 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
81 | // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
82 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83 | // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
84 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85 | // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
86 | // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
87 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88 | // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
89 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
90 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
94 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
96 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98 |
99 | /* Completeness */
100 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101 | "skipLibCheck": true /* Skip type checking all .d.ts files. */
102 | },
103 | "include": ["src"],
104 | }
105 |
--------------------------------------------------------------------------------