Learn
🙌 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
andtype
keywords to declare types. interface
is great for typing objects, especially within object-oriented programs.- We can apply an
interface
on aclass
using theimplements
keyword. - Object types can be nested infinitely.
- We can define multiple types and compose them together to organize our code and make it more flexible.
- We can copy the type members of one
interface
into another using theextends
keyword. - We can define variable property names within an object type with an index signature. An index signature uses syntax like:
[propertyName: string]: string
. - It’s possible to make some type members optional, using the
?
operator. The syntax looks likename?: string
.
Use the code editor to polish your understanding of typing objects in TypeScript.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.