1/12
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What are generics in TypeScript?
A way to create reusable, type-safe code by passing types as parameters.
Why use generics instead of any
Generics preserve type information and provide compile-time safety.
What does unknown do?
Forces type checking before usage.
Why is unknown safer than any?
You must narrow the type before using it.
When should you use unknown?
External data (API responses, user input).
What is an enum?
A named set of constant values.
What does Partial<T> do?
Makes all properties optional.
What does Pick do?
Creates a type with selected properties.
What does Omit do?
Removes specific properties from a type.
What does Record do?
Creates an object type with keys K and values V.
What does Readonly do?
Makes all properties immutable.
Main difference between type and interface
→ interface can be extended & merged
→ type is more flexible (unions, primitives)
Why avoid enums in frontend apps?
→ Bundle size, runtime cost, less flexible than unions.