Basics

Challenges

Classes

Cookies

Debugging

Events

External Files

Flow Control

Forms

Functions

Html Elements

Installation

Interfaces

Keywords

Modules

Namespaces

Operators

Reference Files

String

Types

TypeScript - Interface Spaceship Contract Example

This example shows us how to use an Interface to define and require the shape of a used class. Notice that if I try to use this class and not define one of it's required properties, it throws an error.

To use an interface, you need to use the implements keyword : class Spaceship implements SpaceshipContact

Just like c#, if your class has methods with definitions, you cannot provide those definitions in the interface.

Cruiser Example

Fighter Example