๐ `useImportType` false positive when identifier shares a name with a TypeScript type
Opened this issue ยท 1 comments
ahrjarrett commented
Environment information
CLI:
Version: 1.9.4
Color support: true
Platform:
CPU Architecture: aarch64
OS: macos
Environment:
BIOME_LOG_PATH: unset
BIOME_LOG_PREFIX_NAME: unset
BIOME_CONFIG_PATH: unset
NO_COLOR: unset
TERM: "xterm-256color"
JS_RUNTIME_VERSION: "v22.11.0"
JS_RUNTIME_NAME: "node"
NODE_PACKAGE_MANAGER: "pnpm/9.7.1"
Biome Configuration:
Status: Loaded successfully
Formatter disabled: false
Linter disabled: false
Organize imports disabled: true
VCS disabled: false
Workspace:
Open Documents: 0
What happened?
This one's easy to reproduce.
With useImportType
* enabled, biome treats certain term-level identifiers (such as object
) as types, even if the identifier is used as a value in that file.
Since the unsafe
flag is opt-in, this has the potential to cause a runtime exception unless it's caught during review / by our CI/CD pipeline.
Config:
I believe useImportType
is turned on by default, so any configuration that doesn't override it is enough to reproduce.
Repro:
/// ex-01.ts
export namespace object {
export const keys = globalThis.Object.keys
}
This is what I wrote:
/// ex-02.ts
import { object } from "./ex_01.js"
console.log(object.keys(globalThis))
This is what biome changes it to:
/// ex-02.ts
// vvvv
import { type object } from "./ex_01.js"
// vv this now throws
console.log(object.keys(globalThis))
Expected result
It shouldn't add inline type keywords if the identifier is used as a term in that same file.
Code of Conduct
- I agree to follow Biome's Code of Conduct
ematipico commented
I can't reproduce it in the playground, this means it's been fixed. Can you try to latest nightly to confirm?