vscode_deno icon indicating copy to clipboard operation
vscode_deno copied to clipboard

Support more TypeScript LSP code actions

Open jgoux opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

When using the Deno LSP vs the TypeScript LSP, I noticed that some code actions from the TypeScript LSP are not working with Deno:

{
  "deno.enable": true,
  "deno.lint": true,
  "editor.defaultFormatter": "denoland.vscode-deno",
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.ts": "explicit",
    "source.removeUnused.ts": "explicit", // doesn't work
    "source.addMissingImports.ts": "explicit", // doesn't work
    "source.organizeImports.ts": "explicit"
  }
}

Describe the solution you'd like

Feature parity with Typescript LSP would be great. 👍

jgoux avatar Sep 27 '24 23:09 jgoux

I haven't tried these code actions "on save," but I use them quite a bit while editing. If the text cursor is in just the right place (after a symbol that isn't imported, or after an unused import symbol), you will (often, but not always!) be given these code actions as options when you press Command-Period.

dgreensp avatar Oct 25 '24 14:10 dgreensp

@jgoux have you managed to get source.fixAll working? It doesn't work when I test it.

Here's minimal repro:

.vscode/settings.json

{
  "deno.enable": true,
  "deno.lint": true,
  "editor.codeActionsOnSave": {
    "source.fixAll": "always"
  }
}

deno.json

{
  "lint": {
    "rules": {
      "include": ["verbatim-module-syntax"]
    }
  }
}

type.ts

export type Type = unknown;

test.ts

import { Type } from "./type.ts";
let type: Type;

When I save test.ts

Expected outcome: import { Type } from "./type.ts"; gets changed to import type { Type } from "./type.ts";

Actual outcome: nothing changes

zomchak-code avatar Nov 15 '24 15:11 zomchak-code