top | item 31514286

(no title)

arcosdev | 3 years ago

types are so synonymous that there is no reason to use interfaces in TypeScript.

discuss

order

eyelidlessness|3 years ago

There are several reasons to use interfaces in TypeScript:

- they perform better at build-time and in editor

- they have more relaxed rules for recursion

- they can help identify complex types and distinguish them from simpler ones

- they’re guaranteed to be usable to enforce class implementations, whereas only simple types can be used

- they’re much easier to read in type errors

arcosdev|3 years ago

> - they have more relaxed rules for recursion Do you have a source for this? I would like to read more.

monkpit|3 years ago

I would be impressed to see readable, non-trivial TypeScript code that does not use Interface.

Unless you are referring to interface as a concept, and not the keyword in TS.

nawgz|3 years ago

Can you use the “class MyClass implements MyType” keyword with types?? That might be the only reason if you can’t