Key Concepts

Review core concepts you need to learn to master this subject

TypeScript Interface Type

interface Publication { isbn: string; author: string; publisher: string; }

TypeScript allows you to specifically type an object using an interface that can be reused by multiple objects. To create an interface, use the interface keyword followed by the interface name and the typed object.

Advanced Object Types
Lesson 1 of 1
  1. 1
    One of the challenges of writing TypeScript is knowing how to apply types in every situation we’ll encounter within our code. Take a look at this example: class Robot { identify(id: number) { …
  2. 2
    In TypeScript, we can define types in a variety of ways to fit our code. We’ve used the type keyword to define types, however, there’s another way to define types with the interface keyword. Here’…
  3. 3
    The interface keyword in TypeScript is especially good for adding types to a class. Since interface is constrained to typed objects and using class is a way to program with objects, interface and c…
  4. 4
    As our programs grow and become more complex, we’ll need to add more methods and properties to our objects to accommodate more features. In fact, we may need to add nested methods and properties….
  5. 5
    As our data gets nested deeper, we’ll start to have typed objects that become unwieldy to write and read. Take the following type: interface About { general: { id: number; name: string; …
  6. 6
    In TypeScript, it’s not always enough to be able to compose types together. Sometimes it’s convenient to copy all the type members from one type into another type. We can accomplish this with the e…
  7. 7
    When typing objects in TypeScript, sometimes it’s not possible to know the property names for an object, like when we get back information from an outside data source/API. While we may not know the…
  8. 8
    A common scenario in programming is creating a function or class that can take in many arguments, some of which are required, and some that are optional. Every interface within this lesson so far a…
  9. 9
    🙌 Way to go! You have advanced through this entire lesson. No one will object to your superior TypeScript knowledge. Here’s an overview of what we learned: - We can use both interface and type…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo