Skip to content

Order JSDoc @param name completions by declaration order#62679

Closed
jayinmt wants to merge 3 commits intomicrosoft:mainfrom
jayinmt:feature/20183-jsdoc-sort-params
Closed

Order JSDoc @param name completions by declaration order#62679
jayinmt wants to merge 3 commits intomicrosoft:mainfrom
jayinmt:feature/20183-jsdoc-sort-params

Conversation

@jayinmt
Copy link
Copy Markdown

@jayinmt jayinmt commented Oct 27, 2025

Fixes #20183

Summary

  • JSDoc @param name completions now appear in the same order as the function’s parameters.
  • Keeps sortText at Completions.SortText.LocationPriority; relies on response order for ties (avoids changing existing sortText-sensitive tests).
  • Applies to TS and JS; aligns ad‑hoc completions with the /** doc template expansion.

Approach

  • Update getJSDocParameterNameCompletions to:
    • Return entries in parameter declaration order.
    • Skip non-identifier params (e.g., destructured).
    • Filter already-documented params.
    • Respect prefix filtering.

Changed:

  • src/services/jsDoc.ts (getJSDocParameterNameCompletions)

Tests

Added deterministic fourslash tests (no manual blocks):

  • tests/cases/fourslash/jsDocParamCompletion_filterAlreadyDocumented.ts
  • tests/cases/fourslash/jsDocParamCompletion_prefixFiltering.ts
  • tests/cases/fourslash/jsDocParamCompletion_skipDestructured.ts
  • tests/cases/fourslash/jsDocParamCompletion_optionalAndRest.ts
  • tests/cases/fourslash/jsDocParamCompletion_overloadsUseImplementation.ts
  • tests/cases/fourslash/jsDocParamCompletion_jsFile.ts

Existing related tests still pass:

  • tests/cases/fourslash/completionsJsdocParamTypeBeforeName.ts
  • tests/cases/fourslash/jsdocParameterNameCompletion.ts

Risk/compatibility

  • Low; localized to JSDoc @param completions. No API or language changes.

Performance

  • Negligible; single pass over parameters.

Editor impact

  • Editors will show @param name suggestions in declaration order when completing after @param.

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Oct 27, 2025
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Oct 27, 2025
@jayinmt
Copy link
Copy Markdown
Author

jayinmt commented Oct 27, 2025

@microsoft-github-policy-service agree

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Sort jsdoc parameter suggestions by argument position

3 participants