Apologies for the somewhat confusing title.
I have a React.FC (duck-typed) in a .tsx file with a generic component:
interface ITimeSeriesProps<PlotNames extends string> {
/// map from keys to info about a plot
plots: Record<PlotNames, Plot>, // actual Plot type unimportant
/// which ones to show on the plot
show: PlotNames[]
}
const TimeSeries = <PlotNames extends string>(props: ITimeSeriesProps<PlotNames>) => {
...
return <>
...
</>
}
I can use it like this:
<TimeSeries<"test">
plots = {
test: {...} // correctly types this key
}
show: ["test"] // correctly types this entry
>
</TimeSeries>
However, I would prefer if I didn't have to specify the generic parameter <"test">, and that it was infered from the keys of the plots Record actual type. Is this possible?