biomejs/biome

๐Ÿ› Broken useImportType fix when "quickfix.biome": "explicit" is enabled

Closed this issue ยท 5 comments

VS Code version

1.87.2

Extension version

2,2,2

Biome version

1.6.3

Operating system

  • Windows
  • macOS
  • Linux

Description

When there are many type imports, autofix on save in vscode can be buggy

Steps to reproduce

When useImportType rule is enabled, and vscode extension is configured with "quickfix.biome": "explicit", try to edit following code:

import fs, { BigIntOptions, ReadStream, lchownSync } from "fs";
import { Blob, File, Buffer} from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

The result will be

import type fs from "fs";
import { type type BtIntOptions, ReadStream, type lchownSync } from "fs"
import { Blob, File, Buffer} from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

You can continue pressing ctrl+s, and the code will become more and more broken. The issue seems to be exacerbated the more you mix imports that are supposed to be types and are not supposed to be them.

Expected behavior

Cli seems to be applying type to imports correctly. Vscode extension should behave like cli

Does this issue occur when using the CLI directly?

No

Logs

No response

Duplicate of #1550 and #1570. I just tested your code and this will be fixed in #2237.

@Sec-ant , was it supposed to be fixed in 1.6.4? While it's certainly better now, the code above is still broken after format

import type fs from "fs";
import { type BigIntOptions, lchownSync }type  from "fs";
import { type Blob, type File, } from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

@Sec-ant , was it supposed to be fixed in 1.6.4? While it's certainly better now, the code above is still broken after format

import type fs from "fs";
import { type BigIntOptions, lchownSync }type  from "fs";
import { type Blob, type File, } from "buffer"

const a: fs;
const b: BigIntOptions;
const c: lchownSync;
const d: Blob;
const e: File;

I added a demo to show this is fixed in #2237. I don't see any issues when quickfix.biome is enabled (see Test Plan), do you have other settings (maybe formatting) involved?

Wait, I can reproduce the issue... I don't know why it works well on that PR branch... please give me some time to debug. ๐Ÿ˜ข

Thank you!