Hello, World!
In Type Challenges, we use the type system itself to do the assertion.
For this ch
Give generic function types to your functions
Generic types are like function arguments.
Generic type constraints allow us to restrict the possible types a generic type will accept.
Index signatures allow us to handle types where the properties are a non-specific literal value.
Some types can be indexed to lookup a particular value.
keyof
allows us to extract a union of another type's keys.
TypeScript can be more specific than string
or number
. It can remember literal values.
Mapping objects is a foundational skill that allows you to write type translation logic.
Your TypeScript journey starts with these building blocks.
You can create multiple names for the same type.
When you need to create a type from existing JavaScript values, typeof
is the tool for the job.
Default generic arguments allow you to optionally pass a generic argument.
Type unions are a powerful tool that allow you to create a type that's many values all at once.