Skip to content

Fixed a regression related to determining argument index when spread elements are involved - #57637

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 6 commits into
microsoft:mainfrom
Andarist:fix/regression-arg-index
Mar 28, 2024
Merged

Fixed a regression related to determining argument index when spread elements are involved#57637
Daniel Rosenwasser (DanielRosenwasser) merged 6 commits into
microsoft:mainfrom
Andarist:fix/regression-arg-index

Conversation

@Andarist

@AndaristMateusz Burzyński (Andarist) commented Mar 4, 2024

Copy link
Copy Markdown
Contributor

fixes#57622 (comment)
likely fixes#57623 (comment)
likely fixes#57826

the issue is a regression from #56372

Comment threadsrc/services/signatureHelp.ts Outdated
// args without commas. We want to find what index we're at. So we count
// forward until we hit ourselves, only incrementing the index if it isn't a
// comma.
// forward until we hit ourselves.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I removed this part of the comment because I adjusted the behavior (see tests/cases/fourslash/signatureHelpSkippedArgs1.ts). I find the new behavior better and it was easier for me to rewrite those loops while accommodating for that test case.

// arg count by one to compensate.
//
// Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
// we'll have: 'a' '<comma>' '<missing>'

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The mention of <missing> was added here like 9 years ago but the missing node is not used here for years already (I checked against some 3.x versions). When dealing with fn(,,,,) we just get a list of comma tokens

Comment threadsrc/services/signatureHelp.ts Outdated
//// const fn = thisArg[fnName];
//// return function () {
//// return new Promise((resolve) => {
//// fn.call(thisArg, ...arguments, /*1*/);

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Crash from #57622 (comment) happens in completions but it's caused by the same underlying issue. If requested I can add an extra completions-oriented test case too

Comment threadsrc/services/signatureHelp.ts Outdated
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) cherry-pick this to release-5.4

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 28, 2024

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
cherry-pick this to release-5.4✅ Started✅ Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey, Jake Bailey (@jakebailey)! I've created #57987 for you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I get the general gist here, and I don't see much changing in the way of existing tests which I know we spent a bunch of time on regarding picking the right overload. So I think we can take this PR.

Daniel Rosenwasser (DanielRosenwasser) pushed a commit that referenced this pull request Mar 28, 2024
…e-5.4 (#57987)
Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@Andarist
Mateusz Burzyński (Andarist) deleted the fix/regression-arg-index branch March 28, 2024 23:37
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog BugPRs that fix a backlog bug

Projects

None yet

6 participants

@Andarist@jakebailey@typescript-bot@DanielRosenwasser@sandersn@sheetalkamat