F
F
fif2022-02-02 11:34:30
typescript
fif, 2022-02-02 11:34:30

How to write a generic interface?

There is such an object.

export const aside = {
    well: {
        name: "Колодец",
        costs: "200/250/300",
        src: "../images/shop/wells/well-01.png"
    },
    depot: {
        name: "Склад",
        costs: "150/200/250",
        src: "../images/shop/depots/depot-01.png"
    },
    cage: {
        name: "Клетка",
        costs: "100/150/200",
        src: "../images/shop/cages/cage-01.png"
    }
};

And I wrote such an interface.
export interface asideBl {
    well: {
        name: string,
        costs: string,
        src: string
    },
    depot: {
        name: string,
        costs: string,
        src: string
    },
    cage: {
        name: string,
        costs: string,
        src: string
    }
}

How can I make it shorter, just each block has from three (as here) to 12 blocks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2022-02-02
@fif

{
        name: string,
        costs: string,
        src: string
}

Bring it to a separate interface.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question