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; }
Please login to continue.