Introduction to Typescript. Building and Deploying Typescript Project

Introduction to Typescript. Building and Deploying Typescript Project

Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Introduction to TypeScript. Building and Deploying TypeScript Project Trayan Iliev IPT – Intellectual Products & Technologies e-mail: [email protected] web: http://www.iproduct.org Oracle®, Java™ and JavaScript™ are trademarks or registered trademarks of Oracle and/or its affiliates. Microsoft .NET, Visual Studio and Visual Studio Code are trademarks of Microsoft Corporation. Other names may be trademarks of their respective owners. Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 1 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Course Program I 1. Introduction to TypeScript. - 3h 2. Introduction: Concepts of Angular, App Archutecture. Build-in directives and pipes. - 3h 3. Reactive Extensions for JS (RxJS). - 3h 4. Webpack. Angular CLI. AOT. TODO App with Angular CLI- 3h 5. Services. Dependency Injection. - 2h 6. Forms and Simple Validations. - 2h 7. Reactive Forms. Custom Validations and multi-providers. - 2h 8. Custom Pipes. Custom Directives. Renderer2. - 3h 9. Routing and Navigation. Animations. - 3h Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 2 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Course Program II 10. Routing and Navigation 2 (data, resolves, guards, lazy loading). - 3h 11. Zones. Change Detection. - 3h 12. Redux Architecture. Predictable Reactive State Management - NGRX/store. Reselect-style computing of derived data with RxJS. - 3h 13. Predictable Reactive State Management 2 - NGRX/effects. NGRX Router integration. IndexedDB integration. - 3h 14. Working with websockets. Custiom Reactive Web Socket Implementation with RxJS. - 3h 15. Angular i18n. Recap. Q&A. - 3h Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 3 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Introduction to TypeScript: Agenda I 1. Introduction to some ECMAScript 2015 (ES6) new features 2. TypeScript Hello World 3. Configuring, building and deploying TypeScript project – node package manager (npm), package.json, tsconfig.json, @types and npm packages, TypeScript compiler options. 4. Linting TypeScript code – tslint.json 5. Module resolution. Configuring System.js module loader. 6. Introduction to TypeScript – functions, interfaces, classes and constructors. 7. Common types: Boolean, Number, String, Array, Enum, Any, Void. Duck typing. Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 4 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Agenda II 8. Declaring contracts using Interfaces – properties and optional properties, function types, class types, array types, hybrid types, extension of interfaces. 9. Classes – constructors, public/private properties, get and set accessors, static and instance sides. 10.Functions and function types – optional default and rest parameters, function lambdas and use of this, overloads. 11.Using Enums. 12.Modules in TypeScript – namespaces and modules (former internal and external modules), using import and export Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 5 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Agenda 13.Interoperability with external JS libraries – ambient type declarations and ambient modules, typings, @types. 14.Generic type parameters – writing generic functions and classes, generic constructors, bounded generics. 15.Advanced types. Symbols. Declaration merging. Decorators. Using mixins in TypeScript. 16.Production grade integration with build tools – npm, webpack. Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 6 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Where is The Code? Angular 2 and TypeScript Web App Development code is available @GitHub: https://github.com/iproduct/course-angular Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 7 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ EcmaScript 6 – ES 2015, Harmony [https://github.com/lukehoban/es6features] A lot of new features: Modules + module loaders arrows map + set + weakmap + weakset classes proxies enhanced object literals symbols template strings subclassable built-ins destructuring Promises default + rest + spread math + number + string + array + let + const object APIs iterators + for..of binary and octal literals Generators reflect api unicode tail calls Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 8 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ ES6 Classes [http://es6-features.org/] class Shape { class Rectangle extends Shape { constructor (id, x, y) { constructor (id, x, y, width, height) this.id = id { this.move(x, y) super(id, x, y) } this.width = width move (x, y) { this.height = height this.x = x } this.y = y } } class Circle extends Shape { } constructor (id, x, y, radius) { super(id, x, y) this.radius = radius } Copyright © 2003-2017 IPT – Intellectual Products & Technologies} Ltd. All rights reserved. Slide 9 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Block Scope Vars: let [http://es6-features.org/] for (let i = 0; i < a.length; i++) { let callbacks = [] let x = a[i] for (let i = 0; i <= 2; i++) { … callbacks[i] = } function () { return i * 2 } for (let i = 0; i < b.length; i++) { } let y = b[i] … callbacks[0]() === 0 } callbacks[1]() === 2 callbacks[2]() === 4 Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 10 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ ES6 Arrow Functions and this ECMAScript 6: this.nums.forEach((v) => { if (v % 5 === 0) this.fives.push(v) }) ECMAScript 5: var self = this; this.nums.forEach(function (v) { if (v % 5 === 0) self.fives.push(v); }); Source:Copyright http://wiki.commonjs.org/wiki/Modules/1.1 © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 11 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ ES6 Promises [http://es6-features.org/] function msgAfterTimeout (msg, who, timeout) { return new Promise((resolve, reject) => { setTimeout(() => resolve(`${msg} Hello ${who}!`), timeout) }) } msgAfterTimeout("", "Foo", 1000).then((msg) => { console.log(`done after 1000ms:${msg}`); return msgAfterTimeout(msg, "Bar", 2000); }).then((msg) => { console.log(`done after 3000ms:${msg}`) }) Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 12 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ ES6 Promises Source: Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 13 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ Combining ES6 Promises function fetchAsync (url, timeout, onData, onError) { … } fetchPromised = (url, timeout) => { return new Promise((resolve, reject) => { fetchAsync(url, timeout, resolve, reject) }) } Promise.all([ fetchPromised("http://backend/foo.txt", 500), fetchPromised("http://backend/bar.txt", 500), fetchPromised("http://backend/baz.txt", 500) ]).then((data) => { let [ foo, bar, baz ] = data console.log(`success: foo=${foo} bar=${bar} baz=${baz}`) }, (err) => { Copyright console.log(`error: © 2003-2017 IPT – Intellectual ${err}`) Products & Technologies Ltd. All rights reserved. Slide 14 }) Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ JavaScript Module Systems - CommonJS math.js: exports.add = function() { var sum = 0, i = 0, args = arguments, len = args.length; while (i < len) { sum += args[i++]; } return sum; }; increment.js: var add = require('./math').add; exports.increment = function(val) { return add(val, 1); }; Source:Copyright http://wiki.commonjs.org/wiki/Modules/1.1 © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights reserved. Slide 15 Angular 2 and TypeScript IPT – Intellectual Products & Technologies Web Application Development http://www.iproduct.org/ JavaScript Module Systems – AMD I //Calling define with module ID, dependency array, and factory //function define('myModule', ['dep1', 'dep2'], function (dep1, dep2) { //Define the module value by returning a value. return function () {}; }); define(["alpha"], function (alpha) { return { verb: function(){ return alpha.verb() + 2; } }; }); Copyright © 2003-2017 IPT – Intellectual Products & Technologies Ltd. All rights

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    56 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us