TypeScript - Interfaces #2

UPDATE : Based on TypeScript 2.1.4

With optional & Read Only properties


Properties in an interface can be made optional by appending ? to property name, and read only by prefixing readonly.


Indexable Types


In an interface indexable property can be defined using index signature as shown below.


Interface with construct signature


Interfaces with construct signature can be defined using new keyword as given below

But it cannot be used by a static class definition like shown below

Interface with construct signature will be used only by the Class is instantiated as shown below


Share