typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Port `--isolatedModules` and related node builder logic

Open weswigham opened this issue 3 months ago • 0 comments

Heavily WIP with a bunch still TODO - I've spent a lot of time disentangling the circular host structure ID previously used that really doesn't port easily to go and inlining whatever unneeded abstractions I can. In the service of that, there is one new abstraction to decouple ID node lookup logic from the actual node/error generation - the psuedochecker (which, true to its' name, calculates psuedotypes), which mostly corresponds to the node lookup logic in expressionToTypeNode.ts without a lot of the intermingled error handling and node construction. This way the ID type node lookup logic is still "known checker-free", while avoiding trying to dip into the checker/node builder in it.

The primary thing I'm still working on is the replacement for (*nodeBuilderImpl).reuseNode that actually validates that the node is reusable (and triggers the node builder recovery scope otherwise), but this is a non-crashy checkpoint. It can't be merged as a WIP because without the reuseNode improvements, it's a fairly big step backwards in terms of output alignment (the ID logic very aggressively tries to reuse a ton of nodes that need some massaging to work at a different location, resulting in some pretty nonfunctional declarations (lots of uninstantiated Ts copied without regard for correctness)). I also need to add the sanity-checking that used to be (sometimes) done by the canReuseTypeNode chain of host calls (which should now just be a check in a single branch of the new psudoTypeToNode, ensuring it's more reliably checked).

The other-other thing that I really should do as part of this is reenable the node reuse baselines (to track where we do better/worse/different than strada); but that's probably better served as a followup PR, since that will add underlines to every diff in the repo.

weswigham avatar Sep 09 '25 00:09 weswigham