Interfaces serve the same purpose as they do in C# except that instead of using the colon operator, implementing classes use the implements keyword.
- [Instructor] As a first approximation,…interfaces are identical in TypeScript,…except that you use the key word implements,…rather than a colon.…Let's look at a quick demo.…Let's create a new file and call it interfaces dot t s.…And in here, we'll create an interface.…And I'm going to call my interface phone.…Notice that I'm not calling it iPhone.…That tradition is not popular in TypeScript,…as it is in C Sharp.…
Inside phone, I'm going to have a model…for the model of the phone…and I'm going to have a version, which will be a number,…and finally I'm going to have a method ring,…which is of type string.…And notice, as interfaces are in C Sharp,…ring has no implementation.…It's simply a contract saying that anything…that implements this interface will have…these two properties and this method.…
So, let's create our first class…that implements this interface.…We'll call this class traditional phone.…And we're going to say…that it implements phone, our interface.…Now this will not be satisfied until we have a model,…
In this course, Jesse Liberty reviews the fundamentals of TypeScript for the C# developer, including the built-in types, flow controls, and functions. He covers default, optional, and rest parameters; lambda functions; object literals; and the creation and use of custom classes. Plus, learn about other object-oriented features such as inheritance and interfaces. By the end of the course, C# developers should be well on their way to incorporating this flexible and powerful web programming language into their app development workflow.
- Setting up a TypeScript development environment
- Working with types and variables
- Using operators to control flow
- Working with parameters and functions
- Creating classes and objects
- Exploring TypeScript inheritance
- Working with interfaces