Consider the following code snippet:
interface DbType {
id: string,
}
interface RowType extends DbType {
name: string
}
class MyDB<T extends DbType> {
insert(item: T) { }
delete(id: [typeof id]) { }
}
Let's say I create a new instance with new MyDB<RowType>()
, how can I ensure that the delete
method only accepts the same type as DbType.id
?
Any ideas on how to achieve this?