I'm building an application that access an API that returns an object with many unknown keys, each key represents an id of a user.
Example:
const response = {
"random id1": {name: "user1"},
"random id2": {name: "user2"},
...
"random id100": {name: "user100"}
}
I know that if I have just one unknown key I can define using something like:
type MyDefinition = {
[key: string]: Metadata
}
But how can I define an object with so many different keys?

[key: string]allows for multiple unknown keys though, as long as they're all stringstype MyDefinition = { [key: `random id${number}`]: MetaData; }, but that's just if you want it more precise (and it would still not match perfectly, as it allows generic numbers, e.g. "random id1e4")."random id123"but I assume that the actual random ids you're talking about don't have any such constraint on them. In which case you should just use an index signature as @Samathingamajig has suggested (and should probably post as an answer). Index signatures do not restrict to a single key and I'm not sure what gave you that idea; is that something you ran into somewhere?