Skip to content

Improve performance with lazy processing / calculation timeout #50

@finnmerlett

Description

@finnmerlett

I suddenly started having my intellisense hang indefinitely on a cypress project, and after an extension bisect found ts-type-explorer was the issue. Thankfully I solved the problem by lowering the max recursion depth to 4. I figured the type-structure must have branched out too rapidly, but it made me think there must be a better way to handle recusion calculation overload. My suggestions are:

  1. Only explore and find the types when the user expands that part of the type explorer.

    • There is no point collecting n-levels depth of type information if the nodes are collapsed, and this approach would prevent the exponential slowdown as depth increases. It would also remove the need to set a hard cap on the depth explorable.
    • EDIT: I do see that another user asked about this issue, and that the answer was: it was already implemented on some, but tricky to implement on specific types of types
  2. Allow the user to set a calculation timeout at which point to stop further recursing.

    • This could be used instead of a hard depth stop, particularly if the approach was to calculate level n of recursion for the entire tree, before level n+1. This would fit better with a variety of codebase sizes and complexities, and also let the user know what was going wrong if their computer had ground to a halt.

Also to note - I was having my intellisense hang even when I had not focused the type-explorer tab. This feels like a mis-step, I wouldn't mind a delay when opening the tab, if it meant a more performant codebase the rest of the time. A spinner and a "stop calculation" button would be good UI additions too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions