I found myself wanting to create a recursive private function within a class that would iterate through the nested properties of an object, no matter how many levels deep they go.
private loop(item:any) {
for(let property in item){
if (typeof property === "object") {
this.loop(item[property]);
continue;
}
console.log(property)
}
}
It seemed like a pointless function at first, but it caused an error during compilation
The error message stated: 'Type 'never' cannot be used as an index type.'
I honestly have no clue why this error occurred or what it means... I tried looking at the documentation, but all I found was examples related to an unsatisfied switch statement.
This issue is happening when using typescript version 2.3.4
If anyone out there can shed some light on this mystery, I would greatly appreciate it ;)