So I have a function that requires a certain non nullable type. Before calling the function I check if the input parameter is not null but, apparently, typescript can't understand that and complains saying:
Argument of type 'HermiteOctreeNode | undefined' is not assignable to parameter of type 'HermiteOctreeNode'.
Type 'undefined' is not assignable to type 'HermiteOctreeNode'.
if (node.nodeType !== NODE_TYPE_LEAF && node.nodeType !== NODE_TYPE_PSEUDO) {
for (let i = 0; i < node.children.length; i++) {
if (node.children[i] != null) {
rebuildOctreeNode(node, /* node.children[i] HERE /*, i);
}
}