TypeScript · Junior · Question 63 of 75

How do you write a reusable type for an event handler function?

type Handler = (event: MouseEvent) => void;

Explanation

The same can be written as an interface with a call signature, but a type alias is shorter for plain functions.

Further reading

Problem with a question

TypeScript · Junior · question 63

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz