I am currently working on developing a class that will store values for rows and columns, with each row/column identified by a string. I have provided some code below as an example:
class TMatrix<TYPE>{
[idRow: string]: { [idCol: string]: TYPE };
fnset(nmRow: string, nmCol: string, value: TYPE ) {
if (!this[nmRow])
this[nmRow] = {};
this[nmRow][nmCol] = value;
}
buildHtmlTable(){
...
}
}
Although the code above is functional, typescript is generating an error related to the methods:
Property 'fnset' of type '(nmRow: string, nmCol: string, value: TYPE) => void' is not assignable to string index type '{ [idCol: string]: TYPE; }'.ts(2411)
What could be a potential solution or the correct approach to resolve this issue?