-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
When I save a TypeScript file, VS Code automatically adds a type
import for a function that is clearly being called in the code. This breaks the file with a TypeScript error.
This is not a type-only usage, so importing it using import type
is incorrect.
Environment:
- OS: Windows 11 (10.0.26100)
- VS Code: 1.103.2 (user setup)
- Node.js: 22.17.0
- Electron: 37.2.3
- Extensions: All disabled
Problem Summary (in plain terms):
- I have a normal exported function in one file.
- In another file, I call that function.
- When I save, VS Code auto-imports it as a type, not a normal value.
- That makes the code break — it says the function “cannot be used as a value.”
Even though I have "typescript.preferences.preferTypeOnlyAutoImports": true
, it should not blindly apply type
import when the usage is clearly at runtime.
Real Example:
In my setup, this line gets automatically added by VS Code when I save:
import type { myFunction } from "./somewhere";
But in the same file, I’m literally calling it:
myFunction();
That’s not a type — that’s a function call. So the import should be:
import { myFunction } from "./somewhere";
Expected:
VS Code should detect whether the symbol is being used as a runtime value or a type, and apply the correct import form. If it’s being called like a function, it should not be imported using type
.
Notes:
This happened with all extensions disabled. It seems like a bug in how the editor decides whether something should be a type-only import.