You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Repository navigation
Remap JS type nodes in declaration emit to TS constructs or fallback to serialization - #3449
Fixes part 1 (the bug part) of #2533 and handles #3402 as a side-effect.
With the reparser-focused approach, this was generally supposed to be getting handled in the reparser stage (if we supported them) - the js node remapping logic in the node builder was ported just because some bits of it were still port-able (and it's harmless to keep), so is what I'll say is "partially ported" compared to strada, since a ton of jsdoc node kinds were (and still are) outright missing, highlighting that we're in some weird middleground place right now where the AST isn't exactly like strada's, but nor is it fully handled upfront like we'd originally proposed for corsa.
Rather than deferring to that node builder logic like this, IMO, it'd be better to perform all these js-ts type node remappings at parse/reparse time, but since we're only doing a light touch of reparsing right now (object and signature types), this is where we're at, where some remapping logic lives in the parser/reparser so the checker can leverage it, and some in nodecopy for emit.
I'm not familiar with the "the js node remapping logic in the node builder". What does it do?
It's a big part of nodecopy.go (which is also concerned with sanity checking nodes copied into a new context behave the same way, which is actually the part that handles #3402) - it's logic in visitExistingNodeTreeSymbolsWorker that remaps jsdoc node kinds to TS ones and explicitly recognizes js-only type node patterns (for kinds that aren't inherently jsdoc only) and remaps them to the equivalent ts ones. Basically the AST equivalent of what the checker does when looking up types for one of these nodes (but rather than node-> type, it's node->node). There's also a bunch of partial-serialization fallback stuff that ended up getting added over time to better support ID, but that's mostly irrelevant here. There's a lot of comments in it for logic that doesn't seem to hold water anymore (either because of missing syntax kinds or intentional removals) that we used to do in strada. In theory it was all extraneous with the reparser strategy we set out initially (since anything js specific was set to be reparsed into TS constructs), but I ported what I could during the initial port just in case (after all, we could always go back and remove it later as dead code).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes part 1 (the bug part) of #2533 and handles #3402 as a side-effect.
With the reparser-focused approach, this was generally supposed to be getting handled in the reparser stage (if we supported them) - the js node remapping logic in the node builder was ported just because some bits of it were still port-able (and it's harmless to keep), so is what I'll say is "partially ported" compared to strada, since a ton of jsdoc node kinds were (and still are) outright missing, highlighting that we're in some weird middleground place right now where the AST isn't exactly like strada's, but nor is it fully handled upfront like we'd originally proposed for corsa.
Rather than deferring to that node builder logic like this, IMO, it'd be better to perform all these js-ts type node remappings at parse/reparse time, but since we're only doing a light touch of reparsing right now (object and signature types), this is where we're at, where some remapping logic lives in the parser/reparser so the checker can leverage it, and some in
nodecopyfor emit.