├── 01-project-setup
├── index.html
├── package.json
├── src
│ └── app.ts
└── tsconfig.json
├── 02-webpack-typescript
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 03-let-const
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 04-import-export
├── index.html
├── package.json
├── src
│ ├── app.ts
│ └── utils.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 05-arrow-functions
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 06-default-function-params
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 07-object-literal-improvements
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 08-rest-params
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 09-array-spread-operator
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 10-object-spread-operator
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 11-destructuring-arrays-objects
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 12-string-literals
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 13-for-of-loop
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 14-number-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 15-string-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 16-boolean-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 17-any-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 18-implicit-explicit-types
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 19-void-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 20-never-type
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 21-null-undefined-strictnullchecks
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 22-union-literal-types
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 23-function-types
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 24-function-optional-arguments
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 25-function-default-params
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 26-object-types
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 27-array-types-generics
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 28-tuple-types
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 29-type-alias
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 30-type-assertion
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 31-enum-numeric
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 32-enum-string-inlining-members
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 33-basic-interfaces
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 34-interface-functions
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 35-extending-interfaces
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 36-interface-optional-properties
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 37-interface-index-signatures
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 38-classes-introduction
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 39-public-private-members
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 40-readonly-properties
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 41-setters-getters
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 42-inheritance-extends
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 43-abstract-classes
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 44-protected-members
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 45-class-interface-implements
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 46-static-properties-methods
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 47-generics
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
├── 48-overloads
├── index.html
├── package.json
├── src
│ └── app.ts
├── tsconfig.json
├── webpack.config.js
└── yarn.lock
└── README.md
/01-project-setup/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/01-project-setup/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/01-project-setup/src/app.ts:
--------------------------------------------------------------------------------
1 | console.log('Hey TypeScript!');
2 |
--------------------------------------------------------------------------------
/01-project-setup/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/02-webpack-typescript/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/02-webpack-typescript/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/02-webpack-typescript/src/app.ts:
--------------------------------------------------------------------------------
1 | console.log('Ahoy TypeScript!');
2 |
--------------------------------------------------------------------------------
/02-webpack-typescript/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/02-webpack-typescript/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/03-let-const/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/03-let-const/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/03-let-const/src/app.ts:
--------------------------------------------------------------------------------
1 | let pizza = {
2 | name: 'Pepperoni',
3 | price: 25,
4 | };
5 |
6 | if (true) {
7 | let pizza = 25;
8 | }
9 |
10 | // const pizza: any = {
11 | // name: 'Pepperoni',
12 | // price: 25,
13 | // };
14 |
15 | // pizza.toppings = ['pepperoni'];
16 |
--------------------------------------------------------------------------------
/03-let-const/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/03-let-const/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/04-import-export/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/04-import-export/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/04-import-export/src/app.ts:
--------------------------------------------------------------------------------
1 | import { uppercase } from './utils';
2 |
3 | const pizza = 'Pepperoni';
4 |
5 | console.log(uppercase(pizza));
6 |
--------------------------------------------------------------------------------
/04-import-export/src/utils.ts:
--------------------------------------------------------------------------------
1 | export function uppercase(str) {
2 | return str.toUpperCase();
3 | }
4 |
--------------------------------------------------------------------------------
/04-import-export/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/04-import-export/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/05-arrow-functions/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/05-arrow-functions/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/05-arrow-functions/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizzas = [{ name: 'Pepperoni', toppings: ['pepperoni'] }];
2 |
3 | const mappedPizzas = pizzas.map(pizza => pizza.name.toUpperCase());
4 |
--------------------------------------------------------------------------------
/05-arrow-functions/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/05-arrow-functions/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/06-default-function-params/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/06-default-function-params/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/06-default-function-params/src/app.ts:
--------------------------------------------------------------------------------
1 | function multiply(a, b = 25) {
2 | return a * b;
3 | }
4 |
5 | console.log(multiply(5));
6 | console.log(multiply(5, 35));
7 |
--------------------------------------------------------------------------------
/06-default-function-params/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/06-default-function-params/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/07-object-literal-improvements/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/07-object-literal-improvements/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/07-object-literal-improvements/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizza = {
2 | name: 'Pepperoni',
3 | price: 15,
4 | getName() {
5 | return this.name;
6 | },
7 | };
8 |
9 | console.log(pizza.getName());
10 |
11 | const toppings = ['pepperoni'];
12 |
13 | function createOrder(pizza, toppings) {
14 | return { pizza, toppings };
15 | }
16 |
17 | console.log(createOrder(pizza, toppings));
18 |
--------------------------------------------------------------------------------
/07-object-literal-improvements/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/07-object-literal-improvements/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/08-rest-params/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/08-rest-params/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/08-rest-params/src/app.ts:
--------------------------------------------------------------------------------
1 | function sumAll(message, ...arr) {
2 | return arr.reduce((prev, next) => prev + next);
3 | }
4 |
5 | const sum = sumAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
6 |
--------------------------------------------------------------------------------
/08-rest-params/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/08-rest-params/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/09-array-spread-operator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/09-array-spread-operator/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/09-array-spread-operator/src/app.ts:
--------------------------------------------------------------------------------
1 | const toppings = ['bacon', 'chilli'];
2 |
3 | const newToppings = ['pepperoni'];
4 |
5 | const allToppings = [...newToppings, ...toppings];
6 |
7 | console.log(allToppings);
8 |
--------------------------------------------------------------------------------
/09-array-spread-operator/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/09-array-spread-operator/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/10-object-spread-operator/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/10-object-spread-operator/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/10-object-spread-operator/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizza = {
2 | name: 'Pepperoni',
3 | };
4 |
5 | const toppings = ['pepperoni'];
6 |
7 | const order = Object.assign({}, pizza, { toppings });
8 |
9 | const spreadOrder = { ...pizza, toppings };
10 |
11 | console.log(order, spreadOrder);
12 |
--------------------------------------------------------------------------------
/10-object-spread-operator/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "lib": [
7 | "dom",
8 | "es6"
9 | ],
10 | "outDir": "dist",
11 | }
12 | }
--------------------------------------------------------------------------------
/10-object-spread-operator/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/11-destructuring-arrays-objects/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/11-destructuring-arrays-objects/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/11-destructuring-arrays-objects/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizza = {
2 | name: 'Pepperoni',
3 | toppings: ['pepperoni'],
4 | };
5 |
6 | function order({ name: pizzaName, toppings: pizzaToppings }) {
7 | return { pizzaName, pizzaToppings };
8 | }
9 |
10 | const { pizzaName } = order(pizza);
11 |
12 | const toppings = ['pepperoni', 'bacon', 'chilli'];
13 |
14 | const [first, second, third] = toppings;
15 |
16 | function logToppings([first, second, third]: any) {
17 | console.log(first, second, third);
18 | }
19 |
20 | logToppings(toppings);
21 |
--------------------------------------------------------------------------------
/11-destructuring-arrays-objects/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "lib": [
7 | "dom",
8 | "es6"
9 | ],
10 | "outDir": "dist",
11 | }
12 | }
--------------------------------------------------------------------------------
/11-destructuring-arrays-objects/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/12-string-literals/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/12-string-literals/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/12-string-literals/src/app.ts:
--------------------------------------------------------------------------------
1 | const toppings = ['bacon', 'pepperoni'];
2 |
3 | const order = `You have ordered a pizza with ${toppings.length} toppings!`;
4 |
--------------------------------------------------------------------------------
/12-string-literals/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "lib": [
7 | "dom",
8 | "es6"
9 | ],
10 | "outDir": "dist",
11 | }
12 | }
--------------------------------------------------------------------------------
/12-string-literals/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/13-for-of-loop/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/13-for-of-loop/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/13-for-of-loop/src/app.ts:
--------------------------------------------------------------------------------
1 | const toppings = ['pepperoni', 'mushrooms', 'chilli'];
2 |
3 | const pizzaName = 'Pepperoni';
4 |
5 | for (const letter of pizzaName) {
6 | console.log(letter);
7 | }
8 |
9 | for (var i = 0; i < toppings.length; i++) {
10 | console.log(toppings[i]);
11 | }
12 |
13 | toppings.forEach(topping => console.log(topping));
14 |
15 | for (const topping of toppings) {
16 | console.log(topping);
17 | }
18 |
--------------------------------------------------------------------------------
/13-for-of-loop/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": false,
6 | "lib": [
7 | "dom",
8 | "es6"
9 | ],
10 | "outDir": "dist",
11 | }
12 | }
--------------------------------------------------------------------------------
/13-for-of-loop/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/14-number-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/14-number-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/14-number-type/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizzaCost: number = 10;
2 | const pizzaToppings: number = 5;
3 |
4 | function calculatePrice(cost: number, toppings: number): number {
5 | return cost + 1.5 * toppings;
6 | }
7 |
8 | const cost: number = calculatePrice(pizzaCost, pizzaToppings);
9 | console.log(`Pizza costs: ${cost}`);
10 |
--------------------------------------------------------------------------------
/14-number-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/14-number-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/15-string-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/15-string-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/15-string-type/src/app.ts:
--------------------------------------------------------------------------------
1 | const coupon: string = 'pizza25';
2 |
3 | function normalizeCoupon(code: string): string {
4 | return code.toUpperCase();
5 | }
6 |
7 | const couponMessage: string = `Final coupon is ${normalizeCoupon(coupon)}`;
8 |
9 | console.log(couponMessage);
10 |
--------------------------------------------------------------------------------
/15-string-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/15-string-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/16-boolean-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/16-boolean-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/16-boolean-type/src/app.ts:
--------------------------------------------------------------------------------
1 | const pizzas: number = 2;
2 |
3 | function offerDiscount(orders: number): boolean {
4 | return orders >= 3;
5 | }
6 |
7 | if (offerDiscount(pizzas)) {
8 | console.log(`You're entitled to a discount!`);
9 | } else {
10 | console.log(`Order more than 3 pizzas for a discount!`);
11 | }
12 |
--------------------------------------------------------------------------------
/16-boolean-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/16-boolean-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/17-any-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/17-any-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/17-any-type/src/app.ts:
--------------------------------------------------------------------------------
1 | let coupon: any;
2 |
3 | coupon = 25;
4 |
5 | coupon = 'pizza25';
6 |
7 | coupon = true;
8 |
--------------------------------------------------------------------------------
/17-any-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/17-any-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/18-implicit-explicit-types/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/18-implicit-explicit-types/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/18-implicit-explicit-types/src/app.ts:
--------------------------------------------------------------------------------
1 | let implicitCoupon = 'pizza25';
2 | let explicitCoupon: string;
3 |
4 | explicitCoupon = 'pizza25';
5 |
--------------------------------------------------------------------------------
/18-implicit-explicit-types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/18-implicit-explicit-types/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/19-void-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/19-void-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/19-void-type/src/app.ts:
--------------------------------------------------------------------------------
1 | let selectedTopping: string = 'pepperoni';
2 |
3 | function selectTopping(topping: string): void {
4 | selectedTopping = topping;
5 | }
6 |
7 | selectTopping('bacon');
8 |
9 | console.log(selectedTopping);
10 |
--------------------------------------------------------------------------------
/19-void-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/19-void-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/20-never-type/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/20-never-type/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/20-never-type/src/app.ts:
--------------------------------------------------------------------------------
1 | function orderError(error: string): never {
2 | throw new Error(error);
3 | // never going to return a value!
4 | }
5 |
6 | orderError('Something went wrong');
7 |
--------------------------------------------------------------------------------
/20-never-type/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/20-never-type/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/21-null-undefined-strictnullchecks/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/21-null-undefined-strictnullchecks/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/21-null-undefined-strictnullchecks/src/app.ts:
--------------------------------------------------------------------------------
1 | let coupon: string | null = 'pizza25';
2 |
3 | function removeCoupon(): void {
4 | coupon = null;
5 | }
6 |
7 | console.log(coupon);
8 |
9 | removeCoupon();
10 |
11 | console.log(coupon);
12 |
--------------------------------------------------------------------------------
/21-null-undefined-strictnullchecks/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/21-null-undefined-strictnullchecks/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/22-union-literal-types/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/22-union-literal-types/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/22-union-literal-types/src/app.ts:
--------------------------------------------------------------------------------
1 | let pizzaSize: string = 'small';
2 |
3 | function selectSize(size: 'small' | 'medium' | 'large'): void {
4 | pizzaSize = size;
5 | }
6 |
7 | selectSize('large');
8 |
9 | console.log(`Pizza size: ${pizzaSize}`);
10 |
--------------------------------------------------------------------------------
/22-union-literal-types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/22-union-literal-types/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/23-function-types/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/23-function-types/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/23-function-types/src/app.ts:
--------------------------------------------------------------------------------
1 | let sumOrder: (price: number, quantity: number) => number;
2 |
3 | sumOrder = (x, y) => x * y;
4 |
5 | const sum = sumOrder(25, 2);
6 |
7 | console.log(`Total sum: ${sum}`);
8 |
--------------------------------------------------------------------------------
/23-function-types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/23-function-types/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/24-function-optional-arguments/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/24-function-optional-arguments/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/24-function-optional-arguments/src/app.ts:
--------------------------------------------------------------------------------
1 | let sumOrder: (price: number, quantity?: number) => number;
2 |
3 | sumOrder = (x, y) => {
4 | if (y) {
5 | return x * y;
6 | }
7 | return x;
8 | };
9 |
10 | const sum = sumOrder(25);
11 |
12 | console.log(`Total sum: ${sum}`);
13 |
--------------------------------------------------------------------------------
/24-function-optional-arguments/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/24-function-optional-arguments/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/25-function-default-params/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/25-function-default-params/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/25-function-default-params/src/app.ts:
--------------------------------------------------------------------------------
1 | let sumOrder: (price: number, quantity?: number) => number;
2 |
3 | sumOrder = (x, y = 1) => x * y;
4 |
5 | const sum = sumOrder(25, 5);
6 |
7 | console.log(`Total sum: ${sum}`);
8 |
--------------------------------------------------------------------------------
/25-function-default-params/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/25-function-default-params/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/26-object-types/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/26-object-types/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/26-object-types/src/app.ts:
--------------------------------------------------------------------------------
1 | let pizza: { name: string; price: number; getName(): string } = {
2 | name: 'Plain Old Pepperoni',
3 | price: 20,
4 | getName() {
5 | return pizza.name;
6 | },
7 | };
8 |
9 | console.log(pizza.getName());
10 |
--------------------------------------------------------------------------------
/26-object-types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/26-object-types/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/27-array-types-generics/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/27-array-types-generics/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/27-array-types-generics/src/app.ts:
--------------------------------------------------------------------------------
1 | let sizes: number[];
2 |
3 | sizes = [1, 2, 3];
4 |
5 | let toppings: Array;
6 |
7 | toppings = ['pepperoni', 'tomato', 'bacon'];
8 |
--------------------------------------------------------------------------------
/27-array-types-generics/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/27-array-types-generics/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/28-tuple-types/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/28-tuple-types/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/28-tuple-types/src/app.ts:
--------------------------------------------------------------------------------
1 | let pizza: [string, number, boolean];
2 |
3 | pizza = ['Pepperoni', 20, true];
4 |
--------------------------------------------------------------------------------
/28-tuple-types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/28-tuple-types/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/29-type-alias/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/29-type-alias/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/29-type-alias/src/app.ts:
--------------------------------------------------------------------------------
1 | type Size = 'small' | 'medium' | 'large';
2 | type Callback = (size: Size) => void;
3 |
4 | let pizzaSize: Size = 'small';
5 |
6 | const selectSize: Callback = x => {
7 | pizzaSize = x;
8 | };
9 |
10 | selectSize('medium');
11 |
--------------------------------------------------------------------------------
/29-type-alias/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/29-type-alias/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/30-type-assertion/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/30-type-assertion/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/30-type-assertion/src/app.ts:
--------------------------------------------------------------------------------
1 | type Pizza = { name: string; toppings: number };
2 |
3 | const pizza: Pizza = { name: 'Blazing Inferno', toppings: 5 };
4 |
5 | const serialized = JSON.stringify(pizza);
6 |
7 | function getNameFromJSON(obj: string) {
8 | // return (JSON.parse(obj)).name;
9 | return (JSON.parse(obj) as Pizza).name;
10 | }
11 |
12 | getNameFromJSON(serialized);
13 |
--------------------------------------------------------------------------------
/30-type-assertion/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/30-type-assertion/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/31-enum-numeric/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/31-enum-numeric/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/31-enum-numeric/src/app.ts:
--------------------------------------------------------------------------------
1 | enum Sizes {
2 | Small,
3 | Medium,
4 | Large,
5 | }
6 | enum Sizes {
7 | ExtraLarge = 3,
8 | }
9 |
10 | const selectedSize = 2;
11 |
12 | console.log(Sizes.Large, Sizes[selectedSize]);
13 |
--------------------------------------------------------------------------------
/31-enum-numeric/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/31-enum-numeric/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/32-enum-string-inlining-members/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/32-enum-string-inlining-members/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/32-enum-string-inlining-members/src/app.ts:
--------------------------------------------------------------------------------
1 | const enum Sizes {
2 | Small = 'small',
3 | Medium = 'medium',
4 | Large = 'large',
5 | }
6 |
7 | let selected: Sizes = Sizes.Small;
8 |
9 | function updateSize(size: Sizes): void {
10 | selected = size;
11 | }
12 |
13 | updateSize(Sizes.Large);
14 |
15 | console.log(selected);
16 |
--------------------------------------------------------------------------------
/32-enum-string-inlining-members/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/32-enum-string-inlining-members/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/33-basic-interfaces/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/33-basic-interfaces/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/33-basic-interfaces/src/app.ts:
--------------------------------------------------------------------------------
1 | interface Pizza {
2 | name: string;
3 | sizes: string[];
4 | }
5 |
6 | let pizza: Pizza;
7 |
8 | function createPizza(name: string, sizes: string[]): Pizza {
9 | return {
10 | name,
11 | sizes,
12 | };
13 | }
14 |
15 | pizza = createPizza('Pepperoni', ['small', 'medium']);
16 |
--------------------------------------------------------------------------------
/33-basic-interfaces/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/33-basic-interfaces/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/34-interface-functions/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/34-interface-functions/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/34-interface-functions/src/app.ts:
--------------------------------------------------------------------------------
1 | interface Pizza {
2 | name: string;
3 | sizes: string[];
4 | getAvailableSizes(): void;
5 | }
6 |
7 | let pizza: Pizza;
8 |
9 | function createPizza(name: string, sizes: string[]): Pizza {
10 | return {
11 | name,
12 | sizes,
13 | getAvailableSizes() {
14 | return this.sizes;
15 | },
16 | };
17 | }
18 |
19 | pizza = createPizza('Pepperoni', ['small', 'medium']);
20 |
--------------------------------------------------------------------------------
/34-interface-functions/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/34-interface-functions/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/35-extending-interfaces/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/35-extending-interfaces/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/35-extending-interfaces/src/app.ts:
--------------------------------------------------------------------------------
1 | interface Sizes {
2 | sizes: string[];
3 | }
4 |
5 | interface Pizza extends Sizes {
6 | name: string;
7 | getAvailableSizes(): void;
8 | }
9 |
10 | let pizza: Pizza;
11 |
12 | function createPizza(name: string, sizes: string[]): Pizza {
13 | return {
14 | name,
15 | sizes,
16 | getAvailableSizes() {
17 | return this.sizes;
18 | },
19 | };
20 | }
21 |
22 | pizza = createPizza('Pepperoni', ['small', 'medium']);
23 |
--------------------------------------------------------------------------------
/35-extending-interfaces/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/35-extending-interfaces/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/36-interface-optional-properties/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/36-interface-optional-properties/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/36-interface-optional-properties/src/app.ts:
--------------------------------------------------------------------------------
1 | interface Sizes {
2 | sizes: string[];
3 | }
4 |
5 | interface Pizza extends Sizes {
6 | name: string;
7 | toppings?: number;
8 | getAvailableSizes(): void;
9 | }
10 |
11 | let pizza: Pizza;
12 |
13 | function createPizza(name: string, sizes: string[]): Pizza {
14 | return {
15 | name,
16 | sizes,
17 | getAvailableSizes() {
18 | return this.sizes;
19 | },
20 | };
21 | }
22 |
23 | pizza = createPizza('Pepperoni', ['small', 'medium']);
24 |
25 | pizza.toppings = 1;
26 |
--------------------------------------------------------------------------------
/36-interface-optional-properties/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/36-interface-optional-properties/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/37-interface-index-signatures/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/37-interface-index-signatures/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/37-interface-index-signatures/src/app.ts:
--------------------------------------------------------------------------------
1 | interface Sizes {
2 | sizes: string[];
3 | }
4 |
5 | interface Pizza extends Sizes {
6 | name: string;
7 | toppings?: number;
8 | getAvailableSizes(): void;
9 | [key: number]: string;
10 | }
11 |
12 | let pizza: Pizza;
13 |
14 | function createPizza(name: string, sizes: string[]): Pizza {
15 | return {
16 | name,
17 | sizes,
18 | getAvailableSizes() {
19 | return this.sizes;
20 | },
21 | };
22 | }
23 |
24 | pizza = createPizza('Pepperoni', ['small', 'medium']);
25 | pizza[1] = 'xyz';
26 | pizza.toppings = 1;
27 |
--------------------------------------------------------------------------------
/37-interface-index-signatures/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist"
7 | }
8 | }
--------------------------------------------------------------------------------
/37-interface-index-signatures/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/38-classes-introduction/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/38-classes-introduction/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/38-classes-introduction/src/app.ts:
--------------------------------------------------------------------------------
1 | class Pizza {
2 | name: string;
3 | toppings: string[] = [];
4 |
5 | constructor(name: string) {
6 | this.name = name;
7 | }
8 |
9 | addTopping(topping: string) {
10 | this.toppings.push(topping);
11 | }
12 | }
13 |
14 | const pizza = new Pizza('Pepperoni');
15 |
16 | pizza.addTopping('pepperoni');
17 |
18 | console.log(pizza);
19 |
--------------------------------------------------------------------------------
/38-classes-introduction/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/38-classes-introduction/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/39-public-private-members/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/39-public-private-members/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/39-public-private-members/src/app.ts:
--------------------------------------------------------------------------------
1 | class Pizza {
2 | public toppings: string[] = [];
3 |
4 | constructor(private name: string) {}
5 |
6 | public addTopping(topping: string) {
7 | this.toppings.push(topping);
8 | }
9 | }
10 |
11 | const pizza = new Pizza('Pepperoni');
12 |
13 | pizza.addTopping('pepperoni');
14 |
15 | console.log(pizza);
16 |
--------------------------------------------------------------------------------
/39-public-private-members/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/39-public-private-members/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/40-readonly-properties/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/40-readonly-properties/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/40-readonly-properties/src/app.ts:
--------------------------------------------------------------------------------
1 | class Pizza {
2 | public toppings: string[] = [];
3 |
4 | constructor(readonly name: string) {}
5 |
6 | public addTopping(topping: string) {
7 | this.toppings.push(topping);
8 | }
9 | }
10 |
11 | const pizza = new Pizza('Pepperoni');
12 |
13 | pizza.addTopping('pepperoni');
14 |
--------------------------------------------------------------------------------
/40-readonly-properties/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/40-readonly-properties/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/41-setters-getters/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/41-setters-getters/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/41-setters-getters/src/app.ts:
--------------------------------------------------------------------------------
1 | class Sizes {
2 | constructor(public sizes: string[]) {}
3 |
4 | set availableSizes(sizes: string[]) {
5 | this.sizes = sizes;
6 | }
7 |
8 | get availableSizes() {
9 | return this.sizes;
10 | }
11 | }
12 |
13 | const sizes = new Sizes(['small', 'medium']);
14 |
15 | // invoke getter
16 | console.log(sizes.availableSizes);
17 | // invoke setter
18 | sizes.availableSizes = ['medium', 'large'];
19 |
20 | console.log(sizes.availableSizes);
21 |
22 | class Pizza {
23 | public toppings: string[] = [];
24 |
25 | constructor(readonly name: string) {}
26 |
27 | public addTopping(topping: string) {
28 | this.toppings.push(topping);
29 | }
30 | }
31 |
32 | const pizza = new Pizza('Pepperoni');
33 |
34 | pizza.addTopping('pepperoni');
35 |
--------------------------------------------------------------------------------
/41-setters-getters/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/41-setters-getters/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/42-inheritance-extends/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/42-inheritance-extends/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/42-inheritance-extends/src/app.ts:
--------------------------------------------------------------------------------
1 | class Sizes {
2 | constructor(public sizes: string[]) {}
3 |
4 | set availableSizes(sizes: string[]) {
5 | this.sizes = sizes;
6 | }
7 |
8 | get availableSizes() {
9 | return this.sizes;
10 | }
11 | }
12 |
13 | class Pizza extends Sizes {
14 | public toppings: string[] = [];
15 |
16 | constructor(readonly name: string, public sizes: string[]) {
17 | super(sizes);
18 | }
19 |
20 | public addTopping(topping: string) {
21 | this.toppings.push(topping);
22 | }
23 | }
24 |
25 | const pizza = new Pizza('Pepperoni', ['small', 'medium']);
26 | console.log(pizza.availableSizes);
27 | pizza.addTopping('pepperoni');
28 |
--------------------------------------------------------------------------------
/42-inheritance-extends/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/42-inheritance-extends/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/43-abstract-classes/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/43-abstract-classes/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/43-abstract-classes/src/app.ts:
--------------------------------------------------------------------------------
1 | abstract class Sizes {
2 | constructor(public sizes: string[]) {}
3 |
4 | set availableSizes(sizes: string[]) {
5 | this.sizes = sizes;
6 | }
7 |
8 | get availableSizes() {
9 | return this.sizes;
10 | }
11 | }
12 |
13 | class Pizza extends Sizes {
14 | public toppings: string[] = [];
15 |
16 | constructor(readonly name: string, public sizes: string[]) {
17 | super(sizes);
18 | }
19 |
20 | public addTopping(topping: string) {
21 | this.toppings.push(topping);
22 | }
23 | }
24 |
25 | const pizza = new Pizza('Pepperoni', ['small', 'medium']);
26 | console.log(pizza.availableSizes);
27 | pizza.addTopping('pepperoni');
28 |
--------------------------------------------------------------------------------
/43-abstract-classes/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/43-abstract-classes/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/44-protected-members/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/44-protected-members/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/44-protected-members/src/app.ts:
--------------------------------------------------------------------------------
1 | abstract class Sizes {
2 | constructor(protected sizes: string[]) {}
3 |
4 | set availableSizes(sizes: string[]) {
5 | this.sizes = sizes;
6 | }
7 |
8 | get availableSizes() {
9 | return this.sizes;
10 | }
11 | }
12 |
13 | class Pizza extends Sizes {
14 | public toppings: string[] = [];
15 |
16 | constructor(readonly name: string, sizes: string[]) {
17 | super(sizes);
18 | }
19 |
20 | public updateSizes(sizes: string[]) {
21 | this.sizes = sizes;
22 | }
23 |
24 | public addTopping(topping: string) {
25 | this.toppings.push(topping);
26 | }
27 | }
28 |
29 | const pizza = new Pizza('Pepperoni', ['small', 'medium']);
30 |
31 | console.log(pizza.availableSizes);
32 |
33 | pizza.updateSizes(['large']);
34 |
35 | console.log(pizza.availableSizes);
36 |
--------------------------------------------------------------------------------
/44-protected-members/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/44-protected-members/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/45-class-interface-implements/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/45-class-interface-implements/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/45-class-interface-implements/src/app.ts:
--------------------------------------------------------------------------------
1 | interface SizesInterface {
2 | availableSizes: string[];
3 | }
4 |
5 | abstract class Sizes implements SizesInterface {
6 | constructor(protected sizes: string[]) {}
7 |
8 | set availableSizes(sizes: string[]) {
9 | this.sizes = sizes;
10 | }
11 |
12 | get availableSizes() {
13 | return this.sizes;
14 | }
15 | }
16 |
17 | interface PizzaInterface extends SizesInterface {
18 | readonly name: string;
19 | toppings: string[];
20 | updateSizes(sizes: string[]): void;
21 | addTopping(topping: string): void;
22 | }
23 |
24 | class Pizza extends Sizes implements PizzaInterface {
25 | public toppings: string[] = [];
26 |
27 | constructor(readonly name: string, sizes: string[]) {
28 | super(sizes);
29 | }
30 |
31 | public updateSizes(sizes: string[]) {
32 | this.sizes = sizes;
33 | }
34 |
35 | public addTopping(topping: string) {
36 | this.toppings.push(topping);
37 | }
38 | }
39 |
40 | const pizza = new Pizza('Pepperoni', ['small', 'medium']);
41 |
42 | console.log(pizza.availableSizes);
43 |
44 | pizza.updateSizes(['large']);
45 |
46 | console.log(pizza.availableSizes);
47 |
--------------------------------------------------------------------------------
/45-class-interface-implements/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/45-class-interface-implements/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/46-static-properties-methods/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/46-static-properties-methods/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/46-static-properties-methods/src/app.ts:
--------------------------------------------------------------------------------
1 | class Coupon {
2 | static allowed = ['Pepperoni', 'Blazing Inferno'];
3 | static create(percentage: number) {
4 | return `PIZZA_RESTAURANT_${percentage}`;
5 | }
6 | }
7 |
8 | console.log(Coupon.create(25));
9 |
--------------------------------------------------------------------------------
/46-static-properties-methods/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/46-static-properties-methods/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/47-generics/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/47-generics/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/47-generics/src/app.ts:
--------------------------------------------------------------------------------
1 | class Pizza {
2 | constructor(private name: string, private price: number) {}
3 | }
4 |
5 | class List {
6 | private list: T[];
7 |
8 | addItem(item: T): void {
9 | this.list.push(item);
10 | }
11 |
12 | getList(): T[] {
13 | return this.list;
14 | }
15 | }
16 |
17 | const list = new List();
18 |
19 | list.addItem(new Pizza('Pepperoni', 15));
20 |
21 | const pizzas = list.getList();
22 |
23 | class Coupon {
24 | constructor(private name: string) {}
25 | }
26 |
27 | const anotherList = new List();
28 |
29 | anotherList.addItem(new Coupon('PIZZA25'));
30 |
--------------------------------------------------------------------------------
/47-generics/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/47-generics/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/48-overloads/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ultimate Angular: TypeScript Basics
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/48-overloads/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "typescript-basics-seed",
3 | "version": "1.0.0",
4 | "description": "Seed for TypeScript and Webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "webpack-dev-server",
8 | "test": "echo \"Error: no test specified\" && exit 1"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/UltimateAngular/typescript-basics-seed.git"
13 | },
14 | "keywords": ["typescript"],
15 | "devDependencies": {
16 | "awesome-typescript-loader": "3.4.1",
17 | "typescript": "2.6.2",
18 | "webpack": "3.10.0",
19 | "webpack-dev-server": "2.9.7"
20 | },
21 | "author": "Ultimate Angular",
22 | "license": "MIT",
23 | "bugs": {
24 | "url": "https://github.com/UltimateAngular/typescript-basics-seed/issues"
25 | },
26 | "homepage": "https://github.com/UltimateAngular/typescript-basics-seed#readme"
27 | }
28 |
--------------------------------------------------------------------------------
/48-overloads/src/app.ts:
--------------------------------------------------------------------------------
1 | function reverse(str: string): string;
2 | function reverse(arr: T[]): T[];
3 | function reverse(stringOrArray: string | T[]): string | T[] {
4 | if (typeof stringOrArray === 'string') {
5 | return stringOrArray
6 | .split('')
7 | .reverse()
8 | .join('');
9 | }
10 | return stringOrArray.slice().reverse();
11 | }
12 |
13 | reverse('Pepperoni');
14 | reverse(['bacon', 'pepperoni', 'chili', 'mushrooms']);
15 |
--------------------------------------------------------------------------------
/48-overloads/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "commonjs",
5 | "strict": true,
6 | "outDir": "dist",
7 | }
8 | }
--------------------------------------------------------------------------------
/48-overloads/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: './src/app.ts',
3 | output: {
4 | filename: 'app.js',
5 | path: __dirname + './dist',
6 | },
7 | resolve: {
8 | extensions: ['.ts', '.js'],
9 | },
10 | module: {
11 | rules: [{ test: /\.ts$/, use: 'awesome-typescript-loader' }],
12 | },
13 | devServer: {
14 | port: 3000,
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | TypeScript: Basics Course Seed
4 |
5 | Project seed for our comprehensive introduction to TypeScript course.
6 |
7 | ---
8 |
9 |
10 |
11 | ---
12 |
13 | > This repo serves as the seed project for Ultimate Angular's TypeScript Basics course as well as the final solution in stepped branches, come and [learn TypeScript](https://ultimatecourses.com/courses/typescript) with us!
14 |
15 | [Setup and install](#setup-and-install) | [Tasks](#tasks) |
16 | [Resources](#resources)
17 |
18 | ## Setup and install
19 |
20 | Fork this repo from inside GitHub so you can commit directly to your account, or
21 | simply download the `.zip` bundle with the contents inside.
22 |
23 | #### Dependency installation
24 |
25 | During the time building this project, you'll need development dependencies of
26 | which run on Node.js, follow the steps below for setting everything up (if you
27 | have some of these already, skip to the next step where appropriate):
28 |
29 | 1. Download and install [Node.js here](https://nodejs.org/en/download/) for
30 | Windows or for Mac.
31 |
32 | That's about it for tooling you'll need to run the project, let's move onto the
33 | project install.
34 |
35 | #### Project installation and server
36 |
37 | Now you've pulled down the repo and have everything setup, using the terminal
38 | you'll need to `cd` into the directory that you cloned the repo into and run
39 | some quick tasks:
40 |
41 | ```
42 | cd
43 | yarn install
44 | # OR
45 | npm install
46 | ```
47 |
48 | This will then setup all the development and production dependencies we need.
49 |
50 | Now simply run this to boot up the server:
51 |
52 | ```
53 | yarn start
54 | # OR
55 | npm start
56 | ```
57 |
58 | Visit `localhost:3000` to start building.
59 |
60 | ## Tasks
61 |
62 | A quick reminder of all tasks available:
63 |
64 | #### Development server
65 |
66 | ```
67 | yarn start
68 | # OR
69 | npm start
70 | ```
71 |
72 | ## Resources
73 |
74 | There are several resources used inside this course, of which you can read
75 | further about to dive deeper or understand in more detail what they are:
76 |
77 | * [TypeScript Docs](https://www.typescriptlang.org)
78 | * [TypeScript Playground](https://www.typescriptlang.org/play)
79 | * [AST Explorer](https://astexplorer.net)
80 |
--------------------------------------------------------------------------------