Implements Keyword in TypeScript

The implements keyword tells TypeScript that a class must satisfy a specific interface. Learn how it checks your class shape without changing its type or runtime behavior.

7 min read

The implements keyword tells TypeScript: "this class promises to have the shape described by this interface." If the class is missing a required property or method, TypeScript reports an error. That is the entire job - it checks your work and then disappears.

Here is a class that satisfies an interface:

typescripttypescript
interface Pingable {
  ping(): void;
}
 
class Sonar implements Pingable {
  ping() {
    console.log("ping!");
  }
}

Sonar compiles fine because it provides the ping method that the Pingable interface requires.

Here is a class that fails the check:

typescripttypescript
class Ball implements Pingable {
  pong() {
    console.log("pong!");
  }
}

TypeScript checks the Ball class against the Pingable interface and immediately finds the problem. The compiler reports this error before any JavaScript is emitted:

texttext
Class 'Ball' incorrectly implements interface 'Pingable'.
  Property 'ping' is missing in type 'Ball' but required in type 'Pingable'.

Ball has pong but not ping. TypeScript catches the mismatch at compile time, before any code runs.

Implements vs Extends

These two keywords solve fundamentally different problems:

implementsextends
PurposeEnforce a shape contractCreate an inheritance relationship
Runtime effectNoneCopies prototype members
Inherits methods?No. You must write them.Yes. Methods from the base class are available.
Can reference multiple?Yes (implements A, B)No. Only one base class.
Affects instanceof?NoYes

Here they are together in one example:

typescripttypescript
interface Named {
  name: string;
}
class Animal {
  move() { console.log("Moving..."); }
}
class Dog extends Animal implements Named {
  name: string;
  constructor(name: string) {
    super();
    this.name = name;
  }
  woof() { console.log(`${this.name} says woof!`); }
}

Dog inherits move from Animal through extends. It provides name to satisfy the Named interface through implements. Let us create an instance and use both the inherited and own methods:

typescripttypescript
const dog = new Dog("Rex");
dog.move();
dog.woof();

This prints Moving... followed by Rex says woof!, since move comes from the inherited Animal class and woof reads the name field that Named requires.

texttext
Moving...
Rex says woof!

Both keywords work together here: extends gives Dog its behavior, and implements checks that Dog also has the shape Named requires.

Implements Does Not Change the Class Type

One of the most common misconceptions: implements does not flow type information into the class body. It only checks the final result:

typescripttypescript
interface Checkable {
  check(name: string): boolean;
}
 
class NameChecker implements Checkable {
  check(s) {
    return s.toLowerCase() === "ok";
  }
}

The implements keyword does not flow type information backward into the class body. It only checks the final result after you have written everything.

If you expected the parameter s to be inferred as string from the interface, TypeScript does not do that. The compiler produces the following warning because s gets the implicit any type:

texttext
Parameter 's' implicitly has an 'any' type.

Always annotate your parameters explicitly, even when implementing an interface, so the compiler checks the body the same way it would for any other method:

typescripttypescript
class NameChecker implements Checkable {
  check(s: string): boolean {
    return s.toLowerCase() === "ok";
  }
}

Write the types yourself. Implements only verifies that the final class matches the interface. It does not help you write the class body.

Optional Interface Members

An interface member marked as optional does not automatically appear on the implementing class:

typescripttypescript
interface Config {
  host: string;
  port?: number;
}
class ServerConfig implements Config {
  host: string;
  constructor(host: string) { this.host = host; }
}
 
const config = new ServerConfig("localhost");
config.port = 8080;

TypeScript reports this error at compile time, because ServerConfig never declared a port field of its own, even though Config lists it as optional:

texttext
Property 'port' does not exist on type 'ServerConfig'.

Even though port is part of the Config interface, the class only declares host. The optional port is not created on the class just because it appears in the interface. If you need port on the class, add it as a field yourself.

Implementing Multiple Interfaces

A class can implement more than one interface by separating them with commas. The class must satisfy every member from every interface. If the interfaces have conflicting members, TypeScript reports an error.

When to Use Implements

Use implements when you want:

  • A clear, standalone contract that multiple classes can satisfy.
  • To check that a class has the right shape without inheriting behavior.
  • To define an API surface that framework code or external consumers expect.
  • To document what a class is supposed to look like for other developers.

Do not use implements when the class needs to reuse behavior from a base class (use extends instead), when you are just describing data shapes (a plain interface or type alias is usually enough), or when the interface and the class are always used together (if every implementation is tightly coupled to one interface, the interface may be unnecessary).

Common Mistakes

Expecting implements to infer parameter types. It does not. Always annotate method parameters and return types in the implementing class.

Expecting implements to add properties to the class. It does not. If the interface has a property, the class must declare its own field with that name and type.

Confusing implements with extends. Implements checks shape. Extends inherits behavior. Use implements for contracts, extends for code reuse.

Forgetting that implements is compile-time only. There is no implements in the emitted JavaScript. At runtime, the class is just a class. Interfaces do not exist at runtime, so no one can ask "does this object implement interface X?"

For how classes inherit behavior, see abstract classes in TypeScript and inheritance vs composition in TypeScript. For modeling real objects with classes, see model objects with TypeScript classes.

Rune AI

Rune AI

Key Insights

  • implements checks that a class satisfies an interface shape. It does not change the class type or runtime behavior.
  • Unlike extends, implements does not inherit any methods or properties. The class must provide everything.
  • implements does not affect type inference inside the class body. Parameter types must still be annotated explicitly.
  • A class can implement multiple interfaces by separating them with commas.
  • An implemented optional property does not automatically appear on the class. You must declare it if you need it.
RunePowered by Rune AI

Frequently Asked Questions

Does implements change the type of the class?

No. implements only checks that the class satisfies the interface. It does not influence how TypeScript infers parameter types or checks the class body. The class type is determined entirely by its own declarations.

Can a class implement multiple interfaces?

Yes. Write class C implements A, B { ... }. The class must satisfy all members from both interfaces. If the interfaces have conflicting members, TypeScript reports an error.

What is the difference between implements and extends?

extends creates inheritance. The derived class gets all members from the base class at runtime. implements only checks shape compatibility at compile time. It adds no runtime behavior at all.

Conclusion

The implements keyword is a contract checker. It tells TypeScript 'make sure this class looks like this interface' without changing anything about how the class works. It does not inherit methods, does not influence type inference inside the class, and does not exist at runtime. Its only job is to produce a compiler error when the class falls short of the promised shape.