Description
🔎 Search Terms
symbol ( label:"Domain: Completion Lists" OR label:"Domain: TSServer" )
symbol verbatimModuleSyntax
verbatimModuleSyntax
🕗 Version & Regression Information
I can reproduce this in 4.4 (the first version to support symbol indices according to https://stackoverflow.com/a/649435420) and f1d2494 (main at the time of writing)
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
symbol
⏯ Playground Link
https://github.com/sadan4/ts-symbol-auto-import-repro
💻 Code
// exportsSymbol.ts
export const SYM_FOO_BAR = Symbol.for("foo.bar");
export interface ObjWithSym {
[SYM_FOO_BAR]: any;
}
// usesSymbol.ts
import type { ObjWithSym } from "./exportsSymbol";
export declare const thing: ObjWithSym;
function main() {
// uncomment the following line and try tab-completing SYM_FOO_BAR
// thing.
}
After autocompleting, typescript will update the file to be
import type { ObjWithSym, SYM_FOO_BAR } from "./exportsSymbol";
export declare const thing: ObjWithSym;
function main() {
// uncomment the following line and try tab-completing SYM_FOO_BAR
thing[SYM_FOO_BAR]
}
🙁 Actual behavior
SYM_FOO_BAR
is imported by type and not by value
🙂 Expected behavior
ObjWithSym
remains imported by type while SYM_FOO_BAR
is imported by value
Additional information about the issue
When verbatimModuleSyntax
and erasableSyntaxOnly
are enabled, any import will import as type, not just adding to existing imports.
Updating the imports with a quick-fix or tab-completing the computed property works as expected in both versions.
This seems like an issue with auto-importing symbols while an existing type-only import block exists, rather than with any specific compiler options.