Classes

Classes

Documentation

You can create a greeter by instantiating the Greeter object, or create a customized greeter by extending from it.

Code

const myGreeter = new Greeter("hello, world");
myGreeter.greeting = "howdy";
myGreeter.showGreeting();

class SpecialGreeter extends Greeter {
  constructor() {
    super("Very special greetings");
  }
}

Declaration

Use declare class to describe a class or class-like object. Classes can have properties and methods as well as a constructor.

declare class Greeter {
  constructor(greeting: string);

  greeting: string;
  showGreeting(): void;
}
doc_TypeScript
2016-10-04 19:25:04
Comments
Leave a Comment

Please login to continue.