python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
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

Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - http://code-sample.com and http://code-sample.xyz
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like
www.code-sample.com/. Powered by Blogger.
ASK Questions