Microsoft/TypeScript

Import auto-import doesn't take into account the current import statement

Open

#52,788 创建于 2023年2月15日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
Experience EnhancementHelp WantedSuggestion

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

Bug Report

🔎 Search Terms

  • import
  • auto-import

💻 Code

Use Visual Studio for the following:

  1. In file1.ts, write export zero = 0;
  2. In file2.ts, write import ze and notice the completion entry for zero.

🙁 Actual behavior

If the completion entry for zero is selected, the contents in file2.ts will be replaced by:

import { zero } from "./file1.ts";
import z

After discussing the bug with @andrewbranch, he pointed out how this is the correct behavior because the entry that VS is showing corresponds to an auto-import.

🙂 Expected behavior

The auto-import completion entry shouldn't show up if the current line corresponds to an import statement itself (in case the editor doesn't have preferences.includeCompletionsForImportStatements and preferences.includeCompletionsWithInsertText set).

贡献者指南