develwoutacause’s avatardevelwoutacause’s Twitter Archive—№ 1,599

    1. #TIL a #TypeScript class can implement its own interface. This seems utterly useless other than as an avenue for typos, but I'm kind of amazed it isn't an error? typescriptlang.org/play?#code/MYGwhgzhAEBiD29oEsC2AHEBTVWB2ALjAkgN4BQ0V0ARmAE4AUAlAFzQBu8yAJtKdAC+5YUA
      A snippet of TypeScript code which includes `class Foo implements Foo`, meaning it's implementing its own interface.
  1. …in reply to @develwoutacause
    The plot thickens, apparently you can define an interface and a class as the same symbol, though this doesn't behave in a sound way either. There's probably some historical reason for this, but I can't imagine what it was? typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgGIHt3IN4ChkHIBGcUAFAJQBcyAbusACYDcuAvrggDZwDOvaTMmABbAA5cIIiOAEYseQsTgAvSjXpMcyDkoD0e5ADksJKABpkATwhhkILNCjooAOna5O6ELzsxMNPLIALz2EADuguiUrP7ormYxyAbIAMJwXFygAObKUMjhwGAAFvaOUM5uuHEJqjG4QA
    A TypeScript snippet with an interface `Foo` which defines a function `bar`. Immediately afterwards, it defines a class also named `Foo` which implements `Foo` (whatever that means). The `Foo` class defines a method `baz`, but does *not* define a method `bar`, yet this is not an error. Afterwards a new `Foo` is instantiated and `foo.bar()` and `foo.baz()` are called. Neither of these are marked as errors.