Microsoft/TypeScript

Unwanted auto-imports in script files

Open

#55.256 geöffnet am 3. Aug. 2023

Auf GitHub ansehen
 (14 Kommentare) (0 Reaktionen) (1 zugewiesene Person)TypeScript (6.726 Forks)batch import
Effort: ModerateExperience EnhancementHelp WantedSuggestion

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Bug Report

I have a mixture of module and non-module code. The problem occurs when I edit non-module files (tsconfig: "module": "none").

Sometimes when using auto-completion (in VisualStudio 2022) typescript finds a "matching" name from the module world and adds a line like

import { HmiHelper } from './helper/HmiHelper.js';

into the first line of my file. But as the current file was configured as "module": "none" this import pushes typescript into modules mode and the current code is invalid.

🔎 Search Terms

intellisense auto-import modules

🕗 Version & Regression Information

This bug is many years old and persists in Typescript 5.1.

Contributor Guide