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

Add overload tag

Open sandersn opened this issue 7 months ago • 0 comments

@overload emits a synthetic bodyless function declaration, which then behaves just like a real overload.

To make errors behave nicely, I had to omit some position checks; those errors can't apply to @overload tags anyway. I also removed one @overload-specific error and went back to the standard one.

I ran into the same problem with @template (type parameters) as I saw with @typedef. The fix requires setting Host to a parent synthetic node on nested synthetic nodes, because name resolution always prefers Host for those nodes. I created the signature first, with Parameters and Type nil, so that I could use makeNewType to set the Host in the usual way when creating parameters and return type. Then I set the Parameters and Type afterward.

I applied that same fix to @typedef but it still didn't instantiate the type parameters correctly, so I'm going to fix it in a separate PR.

There is a good deal of churn because I also removed JSDocPropertyTag as a separate type -- it's now a JSDocParameterTag with a different kind, just like JSExportAssignment and other reparsed nodes.

sandersn avatar May 21 '25 17:05 sandersn