DEV Community

Discussion on: Create object property string path generator with typescript

Collapse
 
bregy1 profile image
bregy1 • Edited

The code works indeed but should not be used because of infinite recursion. The Compiler will heavily be used and your IDE will be working way less fast. Just so others know. For having a recursion limiting approach checkout "Paths" type of this stackoverflow answer:
stackoverflow.com/questions/584343...

Collapse
 
bwca profile image
Volodymyr Yepishev • Edited

Unfortunately, in practice you can't get infinite recursion, it appears there is some sort of a hidden safeguard against it.

I actually tried to kill the playground page by deliberately applying type helper to a self referencing interface and trying to get hints, which was supposed to give me infinite amount of them and hang everything, but it just doesn't work that way. I wonder what are the checks under the hood that guard against it.

UPT: oh, yeah, there's a safeguard in ts if (instantiationDepth === 50 || instantiationCount >= 5000000) :D

Collapse
 
bregy1 profile image
bregy1

Okay. Well I wrote the comment cuz vscode complained about the error and it was way slower than usual with type checking..

Anyways, nice post and answer : )