-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Sort JSDoc @param completions by argument position #63079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,8 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ///<reference path="fourslash.ts" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Tests that @param completions are sorted by argument position (not alphabetically). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // See https://github.com/microsoft/TypeScript/issues/20183 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /////** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //// * @param /*0*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //// */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -22,8 +25,27 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| //// */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ////function i(foo, bar) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // sortText uses LocationPriority ("11") + zero-padded index to maintain argument order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const locationPriority = completion.SortText.LocationPriority; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| verify.completions( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { marker: ["0", "3", "4"], exact: ["foo", "bar"] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { marker: "1", exact: "bar" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { marker: "2", exact: ["canary", "canoodle"] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| marker: ["0", "3", "4"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exact: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { name: "foo", sortText: locationPriority + "0000" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { name: "bar", sortText: locationPriority + "0001" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| marker: "1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // bar is the second parameter (index 1), already documented foo is filtered out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exact: { name: "bar", sortText: locationPriority + "0001" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+42
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| marker: "2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // canary is index 1, canoodle is index 2 (cat=0, cantaloupe=3 filtered) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exact: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { name: "canary", sortText: locationPriority + "0001" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { name: "canoodle", sortText: locationPriority + "0002" }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+48
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { name: "foo", sortText: locationPriority + "0000" }, | |
| { name: "bar", sortText: locationPriority + "0001" }, | |
| ], | |
| }, | |
| { | |
| marker: "1", | |
| // bar is the second parameter (index 1), already documented foo is filtered out | |
| exact: { name: "bar", sortText: locationPriority + "0001" }, | |
| }, | |
| { | |
| marker: "2", | |
| // canary is index 1, canoodle is index 2 (cat=0, cantaloupe=3 filtered) | |
| exact: [ | |
| { name: "canary", sortText: locationPriority + "0001" }, | |
| { name: "canoodle", sortText: locationPriority + "0002" }, | |
| { name: "foo", sortText: (locationPriority + "0000") as completion.SortText }, | |
| { name: "bar", sortText: (locationPriority + "0001") as completion.SortText }, | |
| ], | |
| }, | |
| { | |
| marker: "1", | |
| // bar is the second parameter (index 1), already documented foo is filtered out | |
| exact: { name: "bar", sortText: (locationPriority + "0001") as completion.SortText }, | |
| }, | |
| { | |
| marker: "2", | |
| // canary is index 1, canoodle is index 2 (cat=0, cantaloupe=3 filtered) | |
| exact: [ | |
| { name: "canary", sortText: (locationPriority + "0001") as completion.SortText }, | |
| { name: "canoodle", sortText: (locationPriority + "0002") as completion.SortText }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
completion.SortTextis a branded string type; usinglocationPriority + "0000"produces a plainstring, which is not type-compatible withcompletion.SortText. Consider constructing the expectedsortTextvalues ascompletion.SortText(e.g., via an explicit cast or small helper that returnscompletion.SortText) to keep the test type-safe and resilient to harness type checking changes.