Typescript: How to convert a string to a type
问题 I am creating a bunch of web components and each of them can emit custom events. As an example here are two simple examples: //MyButton emits 'myButtonPressed' and detail of this type: interface ButtonDetailType { id: string; } //MySlider emits 'mySliderChanging' and details of this type: interface SliderChangingDetailType { id: string; value: number; } emits 'mySliderChanged' and details of this type: interface SliderChangedDetailType { id: string; oldValue: number; newValue: number; } To