Interfaces
Learn about TypeScript interfaces and the benefits of using interfaces.
We'll cover the following...
Although not technically required for application development, we want to introduce TypeScript interfaces and spend a little time exploring them. The reason for this will become clear shortly.
What is an interface?
An interface is a programming feature that helps define an object’s expected structure, serving as a contract of sorts for the class where it’s used.
Let’s say that we have the following method:
Press + to interact
public requestSpecificArea(coords : any) : Observable {return this.http.get(this._api + `locate-region?q=${coords}`);}
It uses Angular’s HttpClient
get
method to return JSON data structure, like ...