O'Reilly logo

Cross-platform Desktop Application Development: Electron, Node, NW.js, and React by Dmitry Sheiko

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Class type

In other languages, we are used to considering interfaces as closely related to classes. TypeScript brings a similar development experience. What is more, while Java and PHP interfaces cannot contain instance properties, TypeScript has no such limitations:

interface Starship { 
  speed: number;  
  speedUp( increment: number ): void; 
} 
 
class LightFreighter implements Starship { 
  speed: number = 0; 
  speedUp( increment: number ): void { 
    this.speed = this.speed + increment; 
  } 
} 
 
let millenniumFalcon = new LightFreighter(); 
millenniumFalcon.speedUp( 100 ); 

With the advance of ES2015/2016, classes are used widely in JavaScript. Yet, TypeScript allows us to set member accessibility. So, we declare a member as public when we permit access to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required