Skip to content

Keep instantiated signature arguments out of parameter lists - #65497

Closed
Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/signature-type-arguments
Closed

Jake Bailey (jakebailey) wants to merge 1 commit into
microsoft:mainfrom
jakebailey:compiler-fixes/signature-type-arguments

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Hover sticks type parameter declarations where type parameter arguments should be. We then have to work around this in emit, the type is a lie, etc.

I think it would be wise to stop doing this and instead smuggle this information on the emit resolver instead, thus making the AST types correct so they could be checked in the future.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Signature serialization loses display arguments across the public API and type-parameter declarations in still-generic instantiations, while synthesized signature metadata accumulates for the checker’s lifetime.

3 open issues
What changed in this PR

Separates instantiated signature type arguments from type-parameter declarations in the compiler’s synthesized AST, using emit-context metadata to support hover rendering.

Changes:

  • Stores signature display arguments separately from AST type-parameter lists.
  • Updates the printer to use that metadata and preserves it when cloning or updating nodes.
  • Adds checker and API regression tests for declaration structure and signature rendering.
File Description
tsc/​internal/​printer/​printer.go Prints signature arguments from emit-context metadata.
tsc/​internal/​printer/​emitcontext.go Stores display arguments and copies them to derived nodes.
tsc/​internal/​checker/​nodebuilderimpl.go Builds display arguments separately from type-parameter declarations.
tsc/​internal/​checker/​checker_test.go Tests AST structure, rendering, cloning, and updates.
packages/​typescript/​test/​sync/​api.test.ts Adds synchronous API declaration-structure coverage.
packages/​typescript/​test/​async/​api.test.ts Adds asynchronous API declaration-structure coverage.

Review effort: Balanced

Comment thread tsc/internal/checker/nodebuilderimpl.go Resolved
// }
// Instantiated arguments are display metadata, not type parameter declarations.
if len(typeArguments) != 0 {
b.e.SetSignatureTypeArguments(node, b.f.NewNodeList(typeArguments))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really matter?

Comment thread tsc/internal/printer/emitcontext.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Signature serialization charges hidden constraints and defaults against the display truncation budget, causing short inferred return objects to be incorrectly truncated.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread tsc/internal/checker/nodebuilderimpl.go Resolved
Signature type parameter lists contain declarations, not the concrete
types used to instantiate calls. Preserve real generic parameters and
their instantiated constraints even when producing signature displays.

Keep instantiation arguments in sparse EmitContext metadata for local
hover rendering instead of adding storage to every functionlike node.
Scope flagged formatting operations so temporary display trees do not
remain on the cached checker context, while ordinary formatting keeps
its existing caches.

Exclude hidden declaration constraints and defaults from visible length
and verbosity accounting without dropping their AST declarations.

Return canonical declaration ASTs through the API without transporting
hover-only metadata. Preserve native signature and arrow formatting,
including clones and updates, and cover instantiated generic methods
through native and sync/async API regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Hidden-declaration serialization can cache a truncated constraint that is later reused in a visible return type despite sufficient display budget.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment on lines +1932 to +1933
b.ctx.approximateLength, b.ctx.truncating = displayLength, displayTruncating
b.ctx.canIncreaseExpansionDepth, b.ctx.expansionTruncated = canIncreaseExpansionDepth, expansionTruncated
@jakebailey
Jake Bailey (jakebailey) marked this pull request as draft November 14, 2026 06:20
@jakebailey

Copy link
Copy Markdown
Member Author

It turns out we need a similar mechanism for another goofy type printing thing; will come up with some combined PR instead.

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants