ABDELLATIF ANAFLOUS
ABDELLATIF ANAFLOUS

Reputation: 1017

How to Define Object type that contains properties as number in Typescript

Hi i'm struggling to create a type for networkConfig, i tried the following one but it's not working properly, notice that property is an Integer!!

type networkConfigType = {
  number: {
    name: string;
    ethUsdPriceFeed: string;
  };
};

const networkConfig  = {
  4: {
    name  : "rinkeby",
    ethUsdPriceFeed: "0x8A753747A1Fa494EC906cE90E9f37563A8AF630e",
  },
137: {
      name: "polygon",
      ethUsdPriceFeed: "0xF9680D99D6C9589e2a93a78A04A279e509205945",
    },
};

Upvotes: -1

Views: 1112

Answers (1)

Mike
Mike

Reputation: 831

type networkConfigType = Record<number, {
    name: string;
    ethUsdPriceFeed: string;
}>;

Upvotes: 2

Related Questions