I am looking to create a generic Table Row interface that will only allow objects with primitive attribute values. However, when I try to assign a specific type of object to the row, it fails. Why is this happening and how can I make it work? My goal is to restrict rows to objects with primitive attribute values.
// Defining a Table Row
export type Row = Record<string, string | number | undefined>
// Example User Interface
interface User { name: string }
const jim: User = { name: 'Jim' }
const row: Row = jim // <== Error
Error Message:
Type 'User' is not assignable to type 'Row'.
Index signature for type 'string' is missing in type 'User'.