Typescript introductory tutorial
What is Typescript:
“Typescript is a typed superset of Javascript that compiles to plain javascript”:- Typescriptlang.org
Typescript is a next generation of Javascript framework developed and maintained by Microsoft under Open Source License. By using this javascript framework we can using javascript as a real world modeling. Because we can write code like any other programming language that support object orientation. Similarity we can use all features of Object Orientation by using Typescript. Although Javascript is not Object Oriented language. Instead its an function Oriented language. Typescript provides a command line utility that change object oriented code into function oriented language that is understood by all browsers.
Why Typescript/Advantages of typescript:
Javascript is a loosly typed language that is not strict on following data types. Also it doesn’t provides any mode to create any variable as public, private and protected. These things are available using Typescript. In the nutshell it provides an object oriented version of javascript that provides manageable code. There are multiple reason to choose Typescript for your next projects javascript framework:
- Create a class as reusable module
- Using Jquery under it
- Strongly typed language
- Open Source
- Maintained by Microsoft
- Transpiles to a configurable JavaScript version
- Uses ES3/ES6/ES7 syntax if possible
The other advantages of using typescript is:
- Mistake are detected up front
- Less Bugs
- Autocompletes/ Intellisense
- Makes endless type checking unnecessary
- Bottom line : it saves you a lot of time
Future of Typescript
Since this JS framework is developed and maintained by microsoft and being best suitable for angular 2 (a google’s framework) so it always makes us positive in terms of future of Typescript. Certainly it will rock in near future.
Alternative of Typescript
Although Typescript is not the only one language provides the way to write Object Oriented supported code. But we have certain other alternatives as well. Which are like as below:
- Dart – http://dartlang.org
- CoffeeScript – http://coffeescript.org
- By Appling any JavaScript patterns
Object Orientation with Typescript:
Important keywords and operators
Class: Containers of memberfunctions and properties
Constructor: Initialization function of a class
Export : Export a member from a module
Extends: Extend a class or interface
Implements : Implements an interface
Imports: Import a module
Interface : Define code contract that can be implemented by types
Module/namespace: container fro classes and other code
Public/Private: Member visiblity modifiers
… Rest parameter syntax
=> Arrow syntax used with definition and functions
<typename> Character use to case
: Seperation between variables, Parameters names and types
Related posts:
Chandra Shekhar
Latest posts by Chandra Shekhar (see all)
- Best practices for micro service design - January 23, 2022
- Spring Boot - January 23, 2022
- Java - January 23, 2022
Recent Comments