How do I correctly assign a generic class field to a generic local field?
For example I have this generic interface implemented in a generic class
export interface TableBoxProps<T> {
getDataSource: <T> () => T[];
}
class Container<T> extends React.Component<TableBoxProps<T>, any>{ ... }
and somewhere I have a function where I want to get an entry from the datasource e.g. like this
private onCellClick = (row: number, column: number) => {
let entity:T = this.props.getDataSource()[row]; // error
}
I get the error with the above
[ts] Type '{}' is not assignable to type 'T'
What do I have to change that I can use let entity:T? It works fine with the type any, but I don't want to do that.