top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

    Get Free Article Updates

Facebook Login
Site Registration
Print Preview

What is interface in Typescript?

0 votes
32 views

What is Interface?
An interface is a TypeScript artifact, it is not part of ECMAScript. ... Along with functions, an interface can also be used with a Class as well to define custom types. An interface is an abstract type, it does not contain any code as a class does. It only defines the 'signature' or shape of an API.

Interfaces in TypeScript are similar to interfaces in many object-oriented programming languages. However, in TypeScript, they play the role of defining the "shape" of an object. Objects don't have to explicitly implement interfaces as you would in C# or Java. Instead, interfaces define the expected properties so that the type checker can verify an object with the expected properties is being used.

Interfaces have zero runtime JS impact. There is a lot of power in TypeScript interfaces to declare the structure of variables.

TypeScript classes can implement an interface just like a class in Java or C# might implement an interface. 
 

declare var myPoint: { x: number; y: number; };

interface Point {
    x: number; y: number;
}
declare var myPoint: Point;

Video for Interface

posted Jun 8 by Manish Tiwari

  Promote This Article
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button


Related Articles

What is Typescript?

TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict superset of JavaScript, and adds optional static typing and class-based object-oriented programming to the language.

TypeScript is a superset of JavaScript which primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.

There are two main ways to get the TypeScript tools:

  1. Via npm (the Node.js package manager)
  2. By installing TypeScript’s Visual Studio plugins
The command-line TypeScript compiler can be installed as a Node.js package.
 
Install
npm install -g typescript

Video for Typescript

https://www.youtube.com/watch?v=KrLvnVoSzEA

READ MORE
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...