Skip to content

Port #62361: Make go-to-definition resolve constraint properties for object literals in argument positions#2746

Merged
jakebailey merged 10 commits intomainfrom
copilot/port-go-to-definition-constraint-properties
Feb 13, 2026
Merged

Port #62361: Make go-to-definition resolve constraint properties for object literals in argument positions#2746
jakebailey merged 10 commits intomainfrom
copilot/port-go-to-definition-constraint-properties

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 10, 2026

  • Rename ContextFlagsCompletions to ContextFlagsIgnoreNodeInferences in checker/types.go
  • Update all references to the renamed flag (checker/services.go, checker/jsx.go, ls/completions.go, ls/string_completions.go)
  • Move self-reference detection to definition.go, using GetPropertySymbolsFromContextualType and GetContextualType to match the TypeScript PR pattern closely
  • Remove GetContextualDeclarationsForObjectLiteralElement from checker — no equivalent in TS
  • Build and verify the code compiles
  • Run tests and accept baseline changes for goToDefinitionObjectLiteralProperties2 and goToDefinitionObjectLiteralProperties3
  • Run full test suite — all tests pass
  • Verify diff files are deleted (baselines match TypeScript exactly)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…d add self-reference check for go-to-definition on object literal properties

Port of TypeScript PR #62361: Make go to definition go to the constraint's properties for object literals in argument positions.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Port go to definition for constraint's properties in argument positions Port #62361: Make go-to-definition resolve constraint properties for object literals in argument positions Feb 11, 2026
Copilot AI requested a review from jakebailey February 11, 2026 00:28
@jakebailey
Copy link
Copy Markdown
Member

@copilot No tests got updated, so I don't think this is complete. Maybe some tests are fixed that are in failingTests? Look for the original tests modified in the PR you ported.

…eNodeInferences for proper inference blocking, update baselines

The self-reference check was correctly detecting when property declarations
pointed back to the same object literal, but the retry with IgnoreNodeInferences
was using the internal getApparentTypeOfContextualType which doesn't run through
runWithInferenceBlockedFromSourceNode. Changed to use the public GetContextualType
API which properly blocks inference from the source node, matching TypeScript's
behavior.

Baselines for goToDefinitionObjectLiteralProperties2 and
goToDefinitionObjectLiteralProperties3 now match TypeScript's output exactly
(diff files deleted).

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot No tests got updated, so I don't think this is complete. Maybe some tests are fixed that are in failingTests? Look for the original tests modified in the PR you ported.

Fixed in 8141729. The self-reference detection was working, but the retry was using the internal getApparentTypeOfContextualType instead of the public GetContextualType API, so runWithInferenceBlockedFromSourceNode was never called and the constraint type wasn't returned. Fixed to use GetContextualType(objectLiteral, ContextFlagsIgnoreNodeInferences). Baselines for goToDefinitionObjectLiteralProperties2 and goToDefinitionObjectLiteralProperties3 are now updated and the .diff files are deleted (output matches TypeScript exactly).

… helper functions

Remove unnecessary wrapper functions (GetContextualDeclarationsForObjectLiteralElementWithNode,
getContextualDeclarationsForObjectLiteralElementWorker, getDeclarationsFromContextualType,
getDeclarationsFromType, hasSelfReferenceDeclaration) and put the logic directly in
GetContextualDeclarationsForObjectLiteralElement with the added propertyNameNode parameter.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI requested a review from jakebailey February 11, 2026 01:43
@jakebailey jakebailey marked this pull request as ready for review February 12, 2026 18:00
Copilot AI review requested due to automatic review settings February 12, 2026 18:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports TypeScript PR #62361 into the Go-based TypeScript compiler/language server, improving go-to-definition behavior for object literal properties used as generic arguments by resolving to constraint property declarations (and aligning baseline outputs with upstream TypeScript).

Changes:

  • Renames ContextFlagsCompletions to ContextFlagsIgnoreNodeInferences and updates all call sites to use the new flag.
  • Updates go-to-definition to detect self-referential object literal property definitions and re-run contextual typing with inference blocked to find constraint declarations.
  • Updates fourslash go-to-definition baselines (and removes .diff files where Go output now matches TypeScript exactly).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/checker/types.go Renames contextual typing flag and updates its documentation comment.
internal/checker/services.go Implements inference-blocking behavior for the renamed flag and enhances contextual decl lookup for object literal elements.
internal/checker/jsx.go Updates JSX contextual typing logic to use the renamed flag.
internal/ls/completions.go Uses the renamed flag when requesting contextual types for completion scenarios.
internal/ls/string_completions.go Uses the renamed flag for contextual-type-based string literal completions.
internal/ls/definition.go Passes the property-name node through to contextual declaration lookup to support the new go-to-definition behavior.
testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionObjectLiteralProperties2.baseline.jsonc Baseline updated to reflect corrected go-to-definition targets.
testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionObjectLiteralProperties2.baseline.jsonc.diff Deleted because outputs now match the TypeScript reference.
testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionObjectLiteralProperties3.baseline.jsonc Baseline updated to reflect corrected go-to-definition targets.
testdata/baselines/reference/submodule/fourslash/goToDefinition/goToDefinitionObjectLiteralProperties3.baseline.jsonc.diff Deleted because outputs now match the TypeScript reference.

@jakebailey jakebailey requested a review from gabritto February 12, 2026 20:28
Copilot AI and others added 2 commits February 12, 2026 23:07
…lsFromContextualType

Revert GetContextualDeclarationsForObjectLiteralElement to its original form.
Move the self-reference detection logic from the checker to definition.go's
getDeclarationsFromObjectLiteralElement, matching the TypeScript PR pattern:

1. Use GetContextualType (public API) to get the contextual type
2. Use GetPropertySymbolsFromContextualType to get property symbols
   (handles union discriminant filtering, deduplication, etc.)
3. Check if any property symbol's valueDeclaration self-references
4. If so, retry with ContextFlagsIgnoreNodeInferences
5. Call getDeclarationsFromObjectLiteralElement from the object literal
   property check path in getDeclarationsFromLocation

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Use else-if to avoid calling getDeclarationsFromObjectLiteralElement
twice when the symbol is an object literal property.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Remove GetContextualDeclarationsForObjectLiteralElement from checker/services.go
as it has no equivalent in the original TypeScript code. Simplify
getDeclarationsFromLocation to always call getDeclarationsFromObjectLiteralElement
(matching TS's getDefinitionFromObjectLiteralElement), falling back to
symbol.Declarations. This matches the TypeScript flow where
getDefinitionFromObjectLiteralElement is called for all symbols.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
@jakebailey jakebailey requested a review from gabritto February 13, 2026 00:01
@jakebailey jakebailey added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit ee33e62 Feb 13, 2026
20 checks passed
@jakebailey jakebailey deleted the copilot/port-go-to-definition-constraint-properties branch February 13, 2026 17:14
Copilot AI added a commit that referenced this pull request Feb 25, 2026
…object literals in argument positions (#2746)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants