Command Palette

Search for a command to run...

Hectal
Phase 9: Conditional and Template Literal Types
TypeScript · Exercise 4 of 5 PreviousNext
Advanced

Typed Handler Names

Write Handler<E> that turns an event name such as "click" into the handler name "onClick", using a template literal type and Capitalize.

It must work for a union too: Handler<"click" | "hover"> is "onClick" | "onHover".

What Check tests

  1. Your code has no type errors
  2. "onClick" is accepted
  3. "onclick" is rejected
  4. A union gives both names

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.