Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript interface for object with arbitrary keys? [duplicate]

I have an object that looks like this

{
  "sdfsdkhdfs": 1,
  "jjgtusdf": 2
}

where the keys are randomly generated, and there's an unspecified number of them. I want to create a type for this object in Typescript. How should I do this?

like image 481
gkeenley Avatar asked Nov 17 '25 05:11

gkeenley


1 Answers

interface MyObject { [key: string]: number };
like image 95
Mr. Robot Avatar answered Nov 19 '25 17:11

Mr. Robot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!