TypeScript Interface Function Types and Indexable Types

Interface as Type

Implementing Interface

Demo1:

See the Pen TypeScriptInterfaceDemo1 by kenanhancer (@kenanhancer) on CodePen.

Demo2

See the Pen TypeScriptInterfaceDemo2 by kenanhancer (@kenanhancer) on CodePen.

Extending Interface

Demo3

See the Pen TypeScriptInterfaceDemo3 by kenanhancer (@kenanhancer) on CodePen.

Demo4

See the Pen TypeScriptInterfaceDemo4 by kenanhancer (@kenanhancer) on CodePen.

Optional Property

Demo5

See the Pen TypeScriptInterfaceDemo5 by kenanhancer (@kenanhancer) on CodePen.

Demo6

See the Pen TypeScriptInterfaceDemo6 by kenanhancer (@kenanhancer) on CodePen.

Readonly Property

Demo7

See the Pen TypeScriptInterfaceDemo7 by kenanhancer (@kenanhancer) on CodePen.

Interface as Function Type

Demo8

See the Pen TypeScriptInterfaceDemo8 by kenanhancer (@kenanhancer) on CodePen.

Demo9 – Usage of Type Alias

See the Pen TypeScriptInterfaceDemo9 by kenanhancer (@kenanhancer) on CodePen.

Interface as Indexable Type

Demo10

See the Pen TypeScriptInterfaceDemo10 by kenanhancer (@kenanhancer) on CodePen.

Demo11

See the Pen TypeScriptInterfaceDemo11 by kenanhancer (@kenanhancer) on CodePen.

Demo12

See the Pen TypeScriptInterfaceDemo12 by kenanhancer (@kenanhancer) on CodePen.

Notice that when you move mouse cursor on personTypeFieldNames and personObjectFieldNames variables, popup window show value of variable.

Demo13

See the Pen TypeScriptInterfaceDemo13 by kenanhancer (@kenanhancer) on CodePen.

Demo14

See the Pen TypeScriptInterfaceDemo14 by kenanhancer (@kenanhancer) on CodePen.

Demo15

See the Pen TypeScriptInterfaceDemo15 by kenanhancer (@kenanhancer) on CodePen.

Demo16

See the Pen TypeScriptInterfaceDemo16 by kenanhancer (@kenanhancer) on CodePen.

Interface as Constructor Type

adsf

Leave a Reply

Your email address will not be published. Required fields are marked *