Defining TypeScript
TypeScript is an object-oriented programming language developed and maintained by the Microsoft Corporation. It is a superset of JavaScript and contains all of its elements.
TypeScript totally follows the OOPS concept and with the help of TSC (TypeScript Compiler), we can convert Typescript code (.ts file) to JavaScript (.js file)
A Brief History of TypeScript
In 2010, Anders Hejlsberg (the creator of TypeScript) started working on TypeScript at Microsoft and in 2012 the first version of TypeScript was released to the public (TypeScript 0.8). Although the release of TypeScript was praised by many people around the world, due to the lack of support by major IDEs, it was not majorly adopted by the JavaScript community.
The First Version of TypeScript (TypeScript 0.8) Released to the Public October 2012.
The latest version of Typescript (Typescript 3.0) was released to the public in July 2018 and you can download the latest version here!
Why Should We Use TypeScript?
- TypeScript simplifies JavaScript code, making it easier to read and debug.
- TypeScript is open source.
- TypeScript provides highly productive development tools for JavaScript IDEs and practices, like static checking.
- TypeScript makes code easier to read and understand.
- With TypeScript, we can make a huge improvement over plain JavaScript.
- TypeScript gives us all the benefits of ES6 (ECMAScript 6), plus more productivity.
- TypeScript can help us to avoid painful bugs that developers commonly run into when writing JavaScript by type checking the code.
- Powerful type system, including generics.
- TypeScript is nothing but JavaScript with some additional features.
- Structural, rather than nominal.
- TypeScript code can be compiled as per ES5 and ES6 standards to support the latest browser.
- Aligned with ECMAScript for compatibility.
- Starts and ends with JavaScript.
- Supports static typing.
- TypeScript will save developers time.
- TypeScript is a superset of ES3, ES5, and ES6.
- Functions with optional parameters.
- Functions with REST parameters.
- Generics support.
- Modules support.
What Others Said About TypeScript:
- “We love TypeScript for many things… With TypeScript, several of our team members have said things like ‘I now actually understand most of our own code!’ because they can easily traverse it and understand relationships much better. And we’ve found several bugs via TypeScript’s checks.” — Brad Green, Engineering Director – Angular
- “One of Ionic’s main goals is to make app development as quick and easy as possible, and the tooling support TypeScript gives us with autocompletion, type checking and source documentation really aligns with that.” — Tim Lancina, Tooling Developer – Ionic
- “TypeScript is a smart choice when writing a modern web- or JavaScript-based application. TypeScript’s carefully considered language features and functionality, and its consistently improving tools result in a terrifically productive development experience.” — Aaron Cornelius, Research Fellow – Epic
- “TypeScript helped us to reuse the team’s knowledge and to keep the same team velocity by providing the same excellent developer experience as C#… A huge improvement over plain JavaScript.” — Valio Stoychev, PM Lead – NativeScript
Top TypeScript Features You Might Not Know
Object-Oriented Programming
TypeScript includes a very good set of Object Oriented Programming (OOP) features, that are good to maintain robust and clean code; this improves the code quality and maintainability. These OOP features make TypeScript code very clean and organized.
Example:
class CustomerModel
{
customerId: number;
companyName: string;
contactName: string;
country: string;
}
class CustomerOperation{
addCustomer(customerData: CustomerModel) : number {
//add customer
let customerId =5;// Id returned after save
return customerId;
}
}
Interface:interface ITax {taxpayerId: string;calculateTax(): number;}class IncomeTax implements ITax {taxpayerId: string;calculateTax(): number {return 10000;}}class ServiceTax implements ITax {taxpayerId: string;calculateTax(): number {return 2000;}}
class Customers{public companyname:string;private country:string;}
class Employee{Firstname:string;}class Company extends Employee {Department:string;Role:stringprivate AddEmployee(){this.Department="myDept";this.Role="Manager";this.FirstName="Test";// do the operation}}
function identity<T> (arg: T): T {return arg;}//example showing implementation of genericslet output = identity <string>("myString");let outputl = identity <number> (23);
let testnumber: number = 6;testnumber = "myNumber"; // This will throw an error.testnumber = 5; // This will work
let isDone: boolean = false;isDone = "345"; //This will throw an error.isDone = true; //This will work
class Greeter {private greeting: string;constructor (private message: string) {this.greeting = message;}greet() {return "Hello, " + this.greeting;}}// JavaScript code:var Greeter = (function () {function Greeter(message) {this.greeting = message;}Greeter.prototype.greet = function () {return "Hello, " + this.greeting;};return Greeter;})();
module Company {class Employee {}class EmployeeHelper {targetEmployee: Employee;}export class Customer {}}var obj = new Company.Customer();
class functionOverloading{addCustomer(custId: number);addCustomer(company: string);addCustomer(value: any) {if (value && typeof value == "number") {alert("First overload - " + value);}if (value && typeof value == "string") {alert("Second overload - " + value);}}}
Woori Casino - Hair Art Network
ReplyDeleteI know, for you to 우리 카지노 40 프로 총판 모집 say that this is a casino game made by 에볼루션카지노조작 myself, was created by myself and my husband and wife. It's a new, new 오카다카지노 project 강남 바카라 with 카지노 777 my mother and sister
Play Baccarat, Baccarat and More with New Playtech Platform
ReplyDeletePlaytech has 카지노 launched 우리 카지노 쿠폰 a wide range 신규 바카라 사이트 of casino games with its newest innovation, Baccarat, baccarat, and 코인카지노 조작 baccarat, available from the comfort of 메리트 카지노 주소 your home