I'm fetching some data from an API that looks like this:
features: [
{
featureId: '1',
featureName: 'Damage feature 1',
featureType: 'STRING',
},
{
featureId: '2',
featureName: 'Damage feature 2',
featureType: 'DATETIME',
},
{
featureId: '3',
featureName: 'Damage feature 3',
featureType: 'INTEGER',
},
],
They are of different types, as you can see, they can be an integer, a string, a datetime, many different kinds, and I'm mapping them in a component like this:
interface CategoryFeatureProps {
feature: string;
}
export const CategoryFeature = ({ feature }: CategoryFeatureProps) => {
return (
<p>{feature}</p>
);
};
I'd like to know the correct way in Typescript to prepare the component to expect these different types in the interface.