// Created on savesnippets.com ยท https://savesnippets.com/BtKkfJs6oaliqm type EventName = `on${Capitalize}`; type ClickHandler = EventName<'click'>; // 'onClick' type FocusHandler = EventName<'focus'>; // 'onFocus' // Strongly-typed CSS variable names type CssVar = `--${K}`; const setVar = (el: HTMLElement, k: K, v: string) => el.style.setProperty(`--${k}` as CssVar, v); // Parse "GET /users/:id" โ†’ "GET" + "/users/:id" type Method = 'GET' | 'POST' | 'PUT' | 'DELETE'; type Route = `${M} ${P}`; const handle = (r: Route<'GET', '/users/:id'>) => {}; handle('GET /users/:id'); // โœ“ handle('POST /users/:id'); // โœ—