Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Why do we need TypeScript?

593 views

Published on

A motivation and overview of the new features in TypeScript.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Why do we need TypeScript?

  1. 1. TypeScript Nitay Neeman https://goo.gl/jj5K7x
  2. 2. We will talk about ○ What is TypeScript? ○ Motivation ○ Brief history ○ Main features ○ Conclusions 2
  3. 3. What is TypeScript? “TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict superset of JavaScript, and adds optional static typing and class-based object-oriented programming to the language.” (Definition by Wiki) TypeScript transpiles to pure JavaScript. 3
  4. 4. The meaning of transpiling Compilation - taking source code written in one language and transforming into another. For example: C# -> IL. Transpilation - taking source code written in one language and transforming into another language that has a similar level of abstraction. For example: C++ -> C, Sass / LESS -> CSS. 4
  5. 5. Motivation ○ Syntax checking ○ Code completion ○ Type annotations ○ ES6 support ○ Help us preparing for AngularJS 2.0 5
  6. 6. Brief history ○ 2010 - Microsoft started internal development. ○ 2012 - First release (0.8) of TypeScript. It was supported in Visual Studio only. ○ 2013 - Next release (0.9) for supporting other IDE’s. ○ 2014 - TypeScript 1.0 was released. Meanwhile, AtScript was announced by Google. ○ 2015 - Microsoft and Google announced that AtScript development was abandoned and that features of AtScript would be implemented in TypeScript. 6
  7. 7. The reaction of Microsoft about AtScript.. 7
  8. 8. TypeScript and ECMAScript 6 8
  9. 9. So.. TypeScript includes: ○ Classes ○ Modules ○ Arrow functions ○ Default, optional and rest parameters And all the awesome features of ES6! 9
  10. 10. New basic types ○ Boolean ○ Number (float) ○ String ○ Array (one type) ○ Enum ○ Any - general type ○ Void - empty type 10
  11. 11. Syntax checking The following command: Transpilation output: 11
  12. 12. Interfaces Interfaces define rules on following types: ○ Objects ○ Functions ○ Arrays ○ Classes 12
  13. 13. Interfaces - Objects 13
  14. 14. Interfaces - Functions 14
  15. 15. Interfaces - Classes 15
  16. 16. Generics General types for reusability. 16
  17. 17. Generics - Classes 17
  18. 18. Generics - Constraints 18
  19. 19. Mixins Build a class by partial classes. 19
  20. 20. Declaration Merging Merging of: ○ Multiple interfaces ○ Multiple modules ○ Modules with: ○ Classes ○ Functions ○ Enums 20
  21. 21. Declaration Merging - Interfaces The following are equal: 21
  22. 22. Declaration Merging - Modules In similar way, the following are equal: 22
  23. 23. Declaration Merging - Modules & Classes Exporting of module members into a class: 23
  24. 24. Declaration Merging - Modules & Enums / Functions In the same way, 24 Module - Members Enum Enum object with static members Function Function object with static members
  25. 25. Declaration file (.d.ts) Without this file - TypeScript transpiler will not recognize the code of external JavaScript library. Actually, it guides the transpiler how to structure the code and it provides the desired “type annotation”. Download or build your own. 25
  26. 26. Resources ○ TypeScript Definition ○ Compiling vs Transpiling ○ AtScript History ○ Declaration file ○ TypeScript Handbook ○ TypeScript Playground 26
  27. 27. Questions 27 ?

×