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

Building applications with Node & TypeScript

Building applications with Node & TypeScript

An introduction to TypeScript and how to combine it with NodeJs to create awesome applications.

Marco Talento

April 16, 2016

Transcript

30 slides
  1. About me • R&D Engineer at NOS Inovação (BoldInt Consultant)

    • Sharednode Founder • Open Source Contributor Github: https://github.com/Talento90 Twitter: https://twitter.com/Talento90 LinkedIn: https://www.linkedin.com/in/marcotalento 2
  2. Agenda • Introduction • TS definitions • Tools & IDE’s

    • Project Structure • Demo • Conclusion 3
  3. What is TypeScript? • TypeScript is a typed superset of

    JavaScript that compiles to plain JavaScript. • Includes all features of ES6 and much more: types, interfaces, generics, etc... 4
  4. Why TypeScript? • Easy to learn • Types prevents bugs

    • Makes code more readable • Open Source • Created & maintained by Microsoft 6
  5. How to “TypeScript”? 1. Install TypeScript: npm install -g typescript

    2. Create file app.ts 3. Compile using the command line: tsc app.ts 4. Run the result: node app.js 8
  6. Compiler options Use tsconfig.json to specify the compiler options. tsconfig.json

    - http://www.typescriptlang.org/docs/handbook/tsconfig.json.html 10
  7. What is a TS definition? • Definitions give intellisense and

    module typification. • TypeScript definitions are suffixed by “.d.ts” • Maintainable by community • To reference the modules it’s necessary to include the following line on the top of each TS file: /// <reference path="../../../typings.d.ts" /> 12
  8. TypeScript Definition Manager Typings is a tool to manage and

    install TypeScript definitions. It uses typings.json to handle dependencies. Github: https://github.com/typings/typings How to use it: • Install typings: npm install typings --global • Search for typings: typings search hapi • Install Typings: typings install hapi --ambient --save 15
  9. Third Solution (Perfect) 21 Create and contribute to the community

    http://definitelytyped.org/guides/contributing.html
  10. Tools & IDE’s TSLint - A Linter for the TypeScript

    language. Typedoc - A documentation generator for TypeScript projects. IDE Support: • VS Code (https://code.visualstudio.com/) • Sublime (https://github.com/Microsoft/TypeScript-Sublime-Plugin) • Atom (https://atom.io/packages/atom-typescript) • Vim (https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor- Support#vim) 22
  11. Project Structure src - TS source files. test - all

    application tests must be inside this folder. build - contains all the generated JS files respecting the same structure. 24
  12. Project Structure • gulpfile.js - define your tasks (compile, test,

    etc…) • tsconfig.json - TypeScript compiler options. • tslint.json - TypeScript linter rules • typings.json - Typings Definition Manager • typings.d.ts - Main file that aggregates all definitions. 25
  13. Conclusion & Thoughts 27 • Easier to write scalable &

    reliable code • Improve developers productivity • Can be used everywhere • Better documentation • The community is growing faster

More Decks by Marco Talento

Other Decks in Programming