TypeScript · Junior · Question 63 of 75
How do you write a reusable type for an event handler function?
type Handler = (event: MouseEvent) => void;- ✓Correct answer: With a type alias for a function type
- 2Only with a class
- 3Function types can't be named
Explanation
The same can be written as an interface with a call signature, but a type alias is shorter for plain functions.