I've developed an abstract class structure as shown below:
export abstract class CsvFileReader<T> {
data: T[] = []
constructor(public file: string) {}
abstract mapRow(row: string[]): T
read() {
this.data = this.file
.split('\n')
.map((row: string): string[] => {
return row.split(',')
})
.map(this.mapRow)
}
}
Furthermore, I have created a class that extends from the previously mentioned abstract class:
type matchData = [Date, string, string, number, number, MatchResualts, string]
export class MatchReader extends CsvFileReader<matchData> {
mapRow(row: string[]): matchData {
return [
dateStringToDate(row[0]),
row[1],
row[2],
+row[3],
+row[4],
row[5] as MatchResualts,
row[6],
]
}
}
When I tried to instantiate the reader with:
const reader = new MatchReader(Matches)
An error popped up stating: Generic type 'CsvFileReader' requires 1 type argument(s).
Can someone provide a solution?