Reactjs – Type safe select list in React without type casting?
I'm using a select list in React with TypeScript. const allArtists = ["elvis", "dr dre"] as const; type Artist = (typeof allArtists)[number]; function App() { const [artist, setArtist] = useState<Artist | "">(""); function handleArtistChange(e: React.ChangeEvent<HTMLSelectElement>) { const newArtist = e.target.value…