Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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