The ESLint static code analysis tool flags code where we operate on objects which can be undefined.
Object is possibly ‘undefined’
The end of the red line shows the extent of the object which can be undefined, as the “children” element is defined as optional in the type definition:
To satisfy the linter, we need to add another question mark after “children” to guard against undefined values.
hashTable[parent]?.children?.push(hashTable[element.id]);