I'm trying to create a type to represent a list (hash) of HTTP headers. So this type should be a hash containing only key / string pairs:
type TStringStringHash = {
[key: string]: string
}
But this allows an empty object of type TStringStringHash
to be instantiated:
const foo: TStringStringHash = {}
Which doesn't really make sense in my implementation. I want an object of type TStringStringHash
to hold at least one indexed property:
const foo: TStringStringHash = { foo: "bar" }
Every answer I've found so far addresses how to force either one of two non-indexed optional properties to be assigned, no answer I could find seems to address this particular issue.
I apologize in advance if the answer to this happens to be trivial, but so far I haven't been able to figure this out on my own.
Thanks!