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

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^