11// define solutions and companyName outside of the functions so they can be accessed globally
2- let solutions = [ ] ;
2+ let solutions = [ ] as { id : number , title : string , score : number , url : string } [ ] ;
33let companyName = "Amazon" ;
44
55function main ( ) {
66
77
88 chrome . storage . local . get ( "clickedCompany" , function ( data ) {
99 companyName = data . clickedCompany ;
10- document . getElementById ( "title" ) . textContent = companyName ;
10+ document . getElementById ( "title" ) ! . textContent = companyName ;
1111 document . title = companyName + "'s favorite problems"
1212 } ) ;
1313
1414 addCompanyProblems ( "Score" ) ;
1515
1616 // attach click listeners to table headers for sorting
17- document . getElementById ( '#' ) . addEventListener ( 'click' , ( ) => sortBy ( '#' ) ) ;
18- document . getElementById ( 'Title' ) . addEventListener ( 'click' , ( ) => sortBy ( 'Title' ) ) ;
19- document . getElementById ( 'Score' ) . addEventListener ( 'click' , ( ) => sortBy ( 'Score' ) ) ;
17+ document . getElementById ( '#' ) ! . addEventListener ( 'click' , ( ) => sortBy ( '#' ) ) ;
18+ document . getElementById ( 'Title' ) ! . addEventListener ( 'click' , ( ) => sortBy ( 'Title' ) ) ;
19+ document . getElementById ( 'Score' ) ! . addEventListener ( 'click' , ( ) => sortBy ( 'Score' ) ) ;
2020}
2121
2222// Adds the company problems by sorting method
23- function addCompanyProblems ( sortMethod ) {
23+ function addCompanyProblems ( sortMethod : string ) {
2424 chrome . storage . local . get ( "leetcodeProblems" , function ( data ) {
2525 data . leetcodeProblems . questions . forEach ( question => {
2626 if ( ! question . companies ) return ;
@@ -43,7 +43,7 @@ function addCompanyProblems(sortMethod) {
4343 }
4444
4545 solutions . forEach ( solution => {
46- const row = table . insertRow ( - 1 ) ;
46+ const row = table ! . insertRow ( - 1 ) ;
4747 row . insertCell ( 0 ) . innerText = solution . id ;
4848 const titleCell = row . insertCell ( 1 ) ;
4949 titleCell . innerHTML = `<a href="${ solution . url } " target="_blank">${ solution . title } </a>` ;
@@ -52,7 +52,7 @@ function addCompanyProblems(sortMethod) {
5252 } ) ;
5353}
5454
55- function sortBy ( column ) {
55+ function sortBy ( column : string ) {
5656 if ( column === 'Score' ) {
5757 solutions . sort ( ( a , b ) => b . score - a . score ) ;
5858 }
0 commit comments