I'm looking for a TypeScript type definition that describes an object with a single property (having any value).
I know that thare are index signatures, e.g.
type X = { [key: string]: any }
or alternatively
type X = Record<string, any>
However this would allow an object like
const obj: X = {
"a": 12,
"b": "c"
}
I'm looking for a type Y that restricts obj to have a single property, representing kind of a "RecordEntry", that is
const obj: Y = {
"a": 12
}
should be fine but
const obj: Y = {
"a": 12,
"b": "c"
}
should be rejected by the compiler.
Is that even possible?