Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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?
Record<string, number>
string
number
interface MyObject { [key: string]: number };
Add a comment
The best you can do here is Record<string, number>.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
Record<string, number>is what you need in this case. it just defines a Record with keys of typestringand values of typenumber