December 2017
Beginner
372 pages
10h 32m
English
The following is the example of how an interface is defined in TypeScript:
interface IArticle{ // properties author:string; title:string; description: string; // optional properties url?: string; //methods getFormattedDate():string;}
An interface is defined by the interface keyword followed by the name. The definition of the interface is placed inside the curly braces. As we can see in the preceding example, we have three properties defined in the interface, with each property having its own data type.
Similar to optional parameters in functions, we can define optional properties in an interface by using the question mark (?), as you can see with the URL property in the preceding example.
The interface also provides a definition ...
Read now
Unlock full access