Thursday, February 28, 2013

Typescript interface syntax

Typescript offers two distinct flavours for declaring the same syntax. Both of these interfaces are identical:


The reason for providing these two ways is because :
C# / classic languages people would like the first syntax as that is how they would most likely use the interface:


The JavaScript folk might prefer the second syntax for it resembles JSON object syntax:


Since types are structural in typescript instace1 can be used anyplace where instance2 can be used.

No comments:

Post a Comment