-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

The TypeScript Workshop
By :

We'll go through a deep dive into TypeScript interfaces in the next chapter. But for now, just know that an interface allows you to describe the data passed to a class when you're creating an object. In the previous exercise code, if we hover over the Team
class on Visual Studio Code, we get the following message:
Figure 4.2: Vague IntelliSense guidance
As you can see in the preceding screenshot, the Visual Studio Code editor's IntelliSense is saying that the players
parameter uses the any
data type. It's not giving us any usage hints here, and this starts to speak to the reason why we need interfaces, because right now, the players
array could be anything. It could be a string, it could be an object, and so on. This is essentially breaking one of the main benefits of using TypeScript in the first place. Ideally, our programs should be declarative to the point that we know exactly what type of data should be passed...