Angular 1 and Angular 2 Integration

What is TypeScript in Angular 2?

What is TypeScript?

TypeScript is a strongly typed, object oriented and compiled language and this language developed and maintained by Microsoft. It was designed by “Anders Hejlsberg” at Microsoft.

It is a superset of JavaScript.  The TypeScript is JavaScript and also has some additional features like static typing and class-based object-oriented programming, automatic assignment of constructor parameters and assigned null values and so on.


Stayed Informed – Learn Angular 2

The entire JavaScript program is valid for TypeScript because the entire TypeScript (.ts) file converted to JavaScript (.js) file after compiled source compiled and this process is automatic.
See in the below compiled project pic.

TypeScript adds support for features such as classes, modules and arrow function syntax as proposed in the ECMAScript 2015 standard.

How to use arrow function?

//Interface
interface IStudent {
    yearOfBirth: number;
    age : () => number;
}

//Base Class
class College {
    constructor(public name: string, public city: string) {
    }
}

//Child Class implements IStudent and inherits from College
class Student extends College implements IStudent {
    firstName: string;
    lastName: string;
    yourAge: number;

    //Constructor            
    constructor(firstName: string, lastName: string, name: string, city: string, yourAge: number) {
        super(name, city);

        this.firstName = firstName;
        this.lastName = lastName;
        this.yourAge = yourAge;
    }

    age () { 
        return this.yourAge;
    }
}

I hope you are enjoying with this post! Please share with you friends. Thank you!!
ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book