useEffect(() => {
const data = promoService.getHeroes();
heroesPromoLoaded(data);
}, [promoHeroes.id, promoService, heroesPromoLoaded]);
interface IData<T> {
id: T;
name: string;
}
interface IDataString extends IData<string> {}
interface IDataNumber extends IData<number> {}
function getIds(): (string | number)[] {
return [1, 2, 3, 4];
}
const myNumberData: IDataNumber[] = getIds().map(id => ({
id: id as number,
name: "123"
}));
const doSomething1 = (ids: number[]) => [];
doSomething1(myNumberData.map(v => v.id));
const myStringData: IDataString[] = getIds().map(id => ({
id: id as string,
name: "123"
}));
const doSomething2 = (ids: string[]) => [];
doSomething2(myStringData.map(v => v.id));
console.log(myNumberData, myStringData);
для начала