-
Couldn't load subscription status.
- Fork 13.1k
Open
Labels
Needs More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
Description
Acknowledgement
- I acknowledge that issues using this template may be closed without further explanation at the maintainer's discretion.
Comment
I was guided here from typescript-language-server/typescript-language-server#1028 , so I’m following up on my question here.
In VSCode 1.105 with TypeScript, auto-completion for symbols sometimes inserts imports with a .js extension and other times with .ts. This inconsistency is problematic for my project.
Example:
export-a.ts:
export function exportA() {}- In
import-a.ts, when I select the completion forexportA, VSCode may insert either:
import { exportA } from "./export-a.js";or:
import { exportA } from "./export-a.ts";My goal is one of the following:
- A clear, documented rule explaining how the extension is chosen; or
- A reliable configuration to force one extension (preferably
.tsfor my project), so the result is deterministic.
Project context:
tsconfig.jsonincludes"allowImportingTsExtensions": trueand"noEmit": true.- In Node.js v24, importing
.tsfiles works without special flags; rewriting to.jscan cause runtime errors. - I understand some bundlers prefer
.js, and that can make sense in other setups. But in this project, I want imports to remain.ts.
Things I’ve observed but can’t fully explain:
- If the active file already contains at least one
import ... from "./*.ts", subsequent auto-imports seem more likely to stay as.ts. - Behavior appears cached until I run Developer: Reload Window.
Questions:
- What is the exact decision logic for choosing
.jsvs.tsin auto-imports? - Is there an official setting (VSCode or TypeScript) to always generate
.ts(or always.js) for auto-imports? - If this behavior is intended, can the rule be documented so users can predict and configure it?
Metadata
Metadata
Assignees
Labels
Needs More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified