0

I've noticed that it's perfectly legal to write

class X implements X {
  ...
}

but I'm unclear on the semantics. What does it actually do? I want it to mean "X is the name of a class, but we will use it as an interface", but I notice you can write this:

class X  {
...
}

interface Y extends X {
}

Which means that implements X isn't adding that. So what does it add?

Michael Lorton
  • 43,060
  • 26
  • 103
  • 144
  • Try checking https://stackoverflow.com/questions/38834625/whats-the-difference-between-extends-and-implements-in-typescript as it seems to touch this topic a bit. – Ismael Miguel Oct 09 '19 at 17:33
  • @Moira — not only is a duplicate, it was inspired by the same example, Inversify's sample `Ninja implements Ninja`. – Michael Lorton Oct 09 '19 at 18:03

1 Answers1

1

It doesn't accomplish anything. It tells the compiler to check that class X implements everything in class X, which of course will always be true.

Russell Davis
  • 8,319
  • 4
  • 40
  • 41