I need to define a method that serializes objects for storage, but the semantics of it require that it can only work with objects whose fields keys are of string type (because they must match the column's names, so they cannot be numbers).
Using a Record<string, unknown> type won't work for this serializer input, because I am supplying it objects that have specific fields defined (like interface Foo {foo: number, bar: string} and these are not assignable to Record<string, unknown>).
Same thing why we cannot do safely assign a List<Cat> to a List<Animal> if List is mutable, but we can if they are immutable .
So I need to either specify that a generic type parameter's keyof T is a subset of string or have a ReadOnlyRecord<string, unknown> that is covariant with any interface that has string keys.
Suggestions?