TypeScript introduces interfaces – a concept very familiar to developers with experience from languages like C# and Java.
Typically interfaces impose a firm contract on the objects implementing them. This allows us to treat the object like it's of a specific type, constrained by the interface definition.
Does this mean the entire object has to match the interface exactly? No, it's ok if the object is a superset of the interface. This is a nice benefit since it allows us to define interfaces for existing objects without having to manually convert them to a new type.
Below is an example of implicit conversion of an anonymous object to an interface.
The above code allows the returned objects to identify as Book objects because of the implicit implementation of the Book interface.