Stream interfaces versus types

What is the difference between stream type definitions?

interface Vehicle {
  start(): void,
  stop(): void
}

type Vehicle = {
  start(): void,
  stop(): void
};

As far as I can tell, they can be used equally.

+6
source share
1 answer

interfaceand typesimilar, and the difference is mostly historical, I think. Recent changes in the implementation of dispersion of properties have also led to behaviors typemore consistent with behavior interface. I believe that the goal is to ultimately make them identical and possibly even remove them interface.

There may be a subtle difference, but for most applications, I don’t think you will notice the difference.

, implements (, class Foo implements Bar {...}), Bar interface - not a type. , . Flow , , , , type, , .

+6

Source: https://habr.com/ru/post/1016043/


All Articles