Port TS#56182: Include source node inferences in string literal completions deeper in arguments#2747
Conversation
…iteral completions deeper in arguments Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
|
@copilot You incorrectly modified a generated test, |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Fixed in 93a0c28. The generated test was reverted to its original state. The issue was that source node inference types (from |
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
…akemanual Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR ports TypeScript PR #56182, which improves string literal completions for deeply nested arguments by including source node inferences. The fix ensures that when typing a string literal value in a property assignment that's inside a call expression, the completions include types both with and without source node inferences, providing more comprehensive completion options.
Changes:
- Added logic to detect when a property assignment value is inside a call-like expression and merge contextual types with and without source node inferences
- Extracted helper functions
toCompletionsFromTypesandtoStringLiteralCompletionsFromTypesfor cleaner code reuse - Fixed test
typeErrorAfterStringCompletionsInNestedCallby moving it to manual tests and correcting the expected sort order - Removed two tests from failing list that now pass with this fix
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/ls/string_completions.go | Added detection of call-like ancestors for PropertyAssignment cases, merging types from ContextFlagsNone and ContextFlagsCompletions; extracted helper functions for type-to-completions conversion |
| internal/fourslash/tests/manual/typeErrorAfterStringCompletionsInNestedCall_test.go | Removed SkipIfFailing marker and fixed expected completion sort order (exact matches now come before user-typed text) |
| internal/fourslash/_scripts/manualTests.txt | Added typeErrorAfterStringCompletionsInNestedCall to manual tests list |
| internal/fourslash/_scripts/failingTests.txt | Removed two now-passing tests: TestStringLiteralCompletionsWithinInferredObjectWhenItsKeysAreUsedOutsideOfIt and TestTypeErrorAfterStringCompletionsInNestedCall |
toCompletionsFromTypesandtoStringLiteralCompletionsFromTypeshelper functions matching TS exactlyfromContextualTypeto use new helperPropertyAssignmentcase ingetStringLiteralCompletionEntriesto include source node inferences when inside a call expressionSortTextLocationPrioritymatching the original TS code (no hack)typeErrorAfterStringCompletionsInNestedCallto manual test viamakemanualand fix sort order there✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.