Skip to content

Order JSDoc @param name completions by declaration order - #62679

Closed
Jay Singh (jdxpch) wants to merge 3 commits into
microsoft:mainfrom
jdxpch:feature/20183-jsdoc-sort-params
Closed

Order JSDoc @param name completions by declaration order#62679
Jay Singh (jdxpch) wants to merge 3 commits into
microsoft:mainfrom
jdxpch:feature/20183-jsdoc-sort-params

Conversation

@jdxpch

Copy link
Copy Markdown

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.

@jdxpch

Copy link
Copy Markdown
Author

@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
Contributor

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