Loading...
type Event = 'click' | 'focus';
type Handler = `on${Event}`; // 'onclick'type Event = 'click' | 'focus';
type Handler = `on${Capitalize<Event>}`; // 'onClick'Capitalize uppercases the first letter, giving camelCase handler names like 'onClick'.
toUpperCase(), since the type alone does not change the string.string stays string.Capitalize changes only the first character; Uppercase changes every character.
Keys can be string | number | symbol. Use Capitalize<string & K> to keep only string keys.