Answer the question
In order to leave comments, you need to log in
How to write an interface for an object?
I have such an object with links names and prices.
const asideBlock = {
links: {
0 : "../images/shop/wells/well-01.png",
1 : "../images/shop/depots/depot-01.png",
2 : "../images/shop/cages/cage-01.png"
},
nameCost: {
"Колодец" : "200",
"Склад" : "150",
"Клетка" : "100",
}
};
Answer the question
In order to leave comments, you need to log in
Something like this:
interface AsideBlock {
links: Record<number, string>;
nameCost: Record<string, `${number}`>;
}
const asideBlock: AsideBlock = {
links: {
0 : "../images/shop/wells/well-01.png",
1 : "../images/shop/depots/depot-01.png",
2 : "../images/shop/cages/cage-01.png"
},
nameCost: {
"Колодец" : "200",
"Склад" : "150",
"Клетка" : "100",
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question