microsoft / microsoft/TypeScript

Unwanted auto-imports in script files

Open
#55,256 14 comments 0 reactions 1 assignee View on GitHub

@andrewbranch is already working on this.

Since Aug 3, 2023.

Effort: Moderate Experience Enhancement Help Wanted Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.