Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TypeScript: JavaScript for on Steroids

TypeScript: JavaScript for on Steroids

This session gives a brief introduction to TypeScript. The source code can be found at https://github.com/toedter/typescript-contacts-demo. TypeScript was created by Microsoft (Anders Hejlsberg) and is licensed under Apache 2.0. The main Web resource is typescriptlang.org. Here you find all information and you can play around live with a nice editor (seeing the original TypeScript and the compiled JavaScript). Currently the TypeScript compiler runs either as a node.js module or using Windows Scripting host. This slide deck is licensed under a Creative Commons Attribution 4.0 International License.

Kai Toedter

June 19, 2015
Tweet

More Decks by Kai Toedter

Other Decks in Programming

Transcript

  1. TypeScript JavaScript on Steroids Kai Tödter 6/23/2015 1 © Kai

    Tödter, Licensed under a Creative Commons Attribution 4.0 International License.
  2. Who am I?  Senior Software System Architect at Siemens

    Building Technologies  Web Technology Fan  Open Source Lover  E-mail: [email protected]  Twitter: twitter.com/kaitoedter  Google+: gplus.to/toedter  Blog: toedter.com/blog 6/23/2015 2 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License.
  3. Show Hands! 6/23/2015 © Kai Tödter, Licensed under a Creative

    Commons Attribution 4.0 International License. 3
  4. After this session I’ll have an idea what TypeScript is

    all about! 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 5
  5. Outline  Why JavaScript scares many Java/OO developers  TypeScript

    Introduction  Demos & Live Coding 6/23/2015 6 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License.
  6. JavaScript? Many Java/OO developers don’t like JavaScript regarding writing larger

    applications. Some reasons are:  No static typing  No reliable code completion (only best guess)  Hard to refactor  Not object-oriented, especially  No structuring mechanisms like Interfaces, Classes, Modules  … 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 7
  7. Who fixes that?  Dart  Great language by Google:

    dartlang.org  Team has to learn new language  Either runs on Dart VM or compiles to JavaScript  CoffeeScript  Ruby-like, concise syntax  Compiles to JavaScript  coffescript.org  BabelJS  JavaScript compiler  babeljs.io  Traceur  JavaScript compiler  github.com/google/traceur-compiler 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 8
  8. TypeScript: Summary  Typed Superset of JavaScript  Almost all

    valid JavaScript is valid TypeScript*  Compiles to JavaScript  Provides optional static type checking at compile time  For most existing JavaScript libraries there are type definitions available  Provides Interfaces, Classes, Modules, Enums, Generics and more  Open Source: Apache 2.0 License  Created by Microsoft * Exceptions mostly related to type inference 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 9
  9. How to get started?  www.typescriptlang.org  Install node.js (nodejs.org)

     Invoke “npm install –g typescript”  Compile a TypeScript file: “tsc myTypeScript.ts”  Results in “myTypeScript.js” 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 10
  10. Play! 6/23/2015 © Kai Tödter, Licensed under a Creative Commons

    Attribution 4.0 International License. 12
  11. Definitely Typed 6/23/2015 © Kai Tödter, Licensed under a Creative

    Commons Attribution 4.0 International License. 13
  12. WebStorm/IntelliJ IDEA 6/23/2015 © Kai Tödter, Licensed under a Creative

    Commons Attribution 4.0 International License. 14
  13. Visual Studio 6/23/2015 © Kai Tödter, Licensed under a Creative

    Commons Attribution 4.0 International License. 16
  14. License  This work is licensed under a Creative Commons

    Attribution 4.0 International License.  See http://creativecommons.org/licenses/by/4.0/ 6/23/2015 © Kai Tödter, Licensed under a Creative Commons Attribution 4.0 International License. 19