GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add option to OrganizeImports for removal only by andrewbranch · Pull Request #50931 · microsoft/TypeScript

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Sep 23, 2022

Copy link
Copy Markdown
Member

Fixes #43141

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@andrewbranch
Remove unused imports
b99e35f
@typescript-bot

TypeScript Bot (typescript-bot) commented Sep 23, 2022

Copy link
Copy Markdown
Contributor

Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping Sheetal Nandi (@sheetalkamat), Andrew Casey (@amcasey), Matt Bierner (@mjbvz), Mine Starks (@minestarks) for you. Feel free to loop in other consumers/maintainers if necessary

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@typescript-bot TypeScript Bot (typescript-bot) assigned Andrew Branch (andrewbranch) Sep 23, 2022
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 23, 2022
andrewbranch
Andrew Branch (andrewbranch) commented Sep 23, 2022
View reviewed changes
Comment thread src/services/types.ts
Comment on lines +585 to +587
/** @deprecated Use `mode` instead */
skipDestructiveCodeActions?: boolean;
mode?: OrganizeImportsMode;

@andrewbranch Andrew Branch (andrewbranch) Sep 23, 2022

Copy link
Copy Markdown
Member Author

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.

I think skipDestructiveCodeActions was vaguely named due to aspirations of being used in more than one place, but it didn’t end up that way. FWIW, VS never picked this argument up, so it’s likely only VS Code that uses it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
andrewbranch
Andrew Branch (andrewbranch) commented Sep 23, 2022
View reviewed changes
Comment thread src/services/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Andrew Branch added 2 commits September 23, 2022 16:04
Andrew Branch
Lint
742ddfa
Andrew Branch
Update baselines
ae0dfb6
@andrewbranch Andrew Branch (andrewbranch) mentioned this pull request Sep 23, 2022
[typescript-language-features] Add removeUnusedImports command microsoft/vscode#161654
Merged
Andarist
Mateusz Burzyński (Andarist) reviewed Sep 25, 2022
View reviewed changes
Comment thread src/server/protocol.ts

export const enum OrganizeImportsMode {
All = "All",
SortAndCombine = "SortAndCombine",

ghost Sep 25, 2022

Copy link
Copy Markdown
Contributor

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.

While the PR focuses on the RemoveUnused... I'm more excited about SortAndCombine :P I see that skipDestructiveCodeActions was a thing (didn't know about it), gonna give it a try in my projects for now

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

ghost Sep 26, 2022

Copy link
Copy Markdown
Member Author

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.

Yeah, to be clear, SortAndCombine ought to be identical to setting skipDestructiveCodeActions which is already set in a VS Code code action called sortImports. (It’s not very discoverable because I learned recently that these code actions lack autocomplete support in the VS Code settings.json files.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

ghost Sep 26, 2022

Copy link
Copy Markdown
Contributor

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.

Ye, I got the fact that this one isn't a new option - but I had no idea that it was already a thing. So I'm glad that I've discovered that old option through this PR :P

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andrewbranch reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

ghost Sep 26, 2022

Copy link
Copy Markdown
Contributor

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.

I can't figure out how to actually use this old option in VS Code. I've found this in the source code:
https://github.com/microsoft/vscode/blob/3a8b1fe03ebbcf57fb9c50b161db91229e2fe04a/extensions/typescript-language-features/src/languageFeatures/organizeImports.ts#L50

I've tried a lot of combinations with _typescript.*, typescript.*, source.* and *.organizeImports.sortOnly: true but none of those work for me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

ghost Sep 26, 2022

Copy link
Copy Markdown
Member Author

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.

  "editor.codeActionsOnSave": {
    "source.sortImports": true
  }

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Andarist, pcreehan, and alecbass reacted with heart emoji
All reactions
  • ❤️ 3 reactions

ghost Sep 26, 2022

Copy link
Copy Markdown
Member Author

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.

I believe Organize Imports is a VS Code standard command, and so automatically appears in the command palette when registered. These variations are registered so can be triggered by ID in configurations like codeActionsOnSave, but I think we would need to add them to the contributes of the extension package.json to show up in the command palette. Matt Bierner (@mjbvz) is that correct?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sheetalkamat
Sheetal Nandi (sheetalkamat) approved these changes Sep 26, 2022
View reviewed changes
Comment thread src/services/organizeImports.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Andrew Branch
Make mode paramter required
0d06478
amcasey
Andrew Casey (amcasey) approved these changes Sep 28, 2022
View reviewed changes

ghost left a comment

Copy link
Copy Markdown
Member

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.

LGTM, though the enum structure feels forced.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/server/protocol.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/server/protocol.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/services/types.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Andrew Branch
Clean up
6b35ddc
@andrewbranch
Andrew Branch (andrewbranch) merged commit 0ce72ef into microsoft:main Sep 29, 2022
@andrewbranch
Andrew Branch (andrewbranch) deleted the feature/43141 branch September 29, 2022 23:37
This was referenced Dec 9, 2022
docs: Add original typescript 4.9 file to translate into Ko microsoft/TypeScript-Website-Localizations#184
Merged
translate "Checks For Equality on NaN" in ko microsoft/TypeScript-Website-Localizations#185
Merged
translate "File-Watching Now Uses File System Events" in ko microsoft/TypeScript-Website-Localizations#186
Merged
translate "Performance Improvements" in ko microsoft/TypeScript-Website-Localizations#187
Merged
translate "satisfies" in ko microsoft/TypeScript-Website-Localizations#188
Merged
translate "Correctness Fixes and Breaking Changes" in ko microsoft/TypeScript-Website-Localizations#190
Merged
translate “Remove Unused Imports and Sort Imports Commands” for Editors in ko microsoft/TypeScript-Website-Localizations#191
Merged
translate 4.9 "in", "auto-accessors" microsoft/TypeScript-Website-Localizations#192
Merged
@github-actions github-actions Bot mentioned this pull request Dec 18, 2022
Rename property in ts 4.9 satisfies section microsoft/TypeScript-Website-Localizations#194
Merged
@SudoPlz

ghost commented Feb 3, 2023

Copy link
Copy Markdown

how do we use a specific mode in our settings.json ?

Are we supposed to do something like:

  "editor.codeActionsOnSave": {
    "source.sortImports": 'all',
  }

?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andrewbranch

ghost commented Feb 3, 2023

Copy link
Copy Markdown
Member Author

The command names are source.organizeImports, source.removeUnusedImports, and source.sortImports.

SudoPlz, augustoicaro, ElfenB, niklasholm, and toddsouthenbentley reacted with heart emoji
All reactions
  • ❤️ 5 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SudoPlz

ghost commented Feb 3, 2023

Copy link
Copy Markdown

thanks Andrew Branch (@andrewbranch)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SamuelT-Beslogic Samuel T. (SamuelT-Beslogic) mentioned this pull request Sep 5, 2024
Add VSCode shared settings BesLogic/shared-configs#2
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@sheetalkamat Sheetal Nandi (sheetalkamat) sheetalkamat approved these changes
+2 more reviewers
@Andarist Mateusz Burzyński (Andarist) Andarist left review comments
@amcasey Andrew Casey (amcasey) amcasey approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@andrewbranch Andrew Branch (andrewbranch)

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

organizeImports without the reordering ("remove unused imports" being its own option)

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@andrewbranch @typescript-bot @SudoPlz @sheetalkamat @Andarist @amcasey
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.