microsoft / microsoft/TypeScript

Broken autoimport of module without index reexport

Open
#40,913 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: Auto-import Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Demo: https://github.com/zerkalica/ts-references-autoimport-bug/tree/no-autoimport-wo-index

TypeScript Version: 4.0.2
VSCode Version: 1.49.2
OS: Ubuntu 20.04.1 LTS

Example 1

Package 'b' depends on 'a', but 'a' has no index.ts and types in package.json.

Steps to reproduce

  1. clone, switch to no-autoimport-wo-index, yarn install
  2. Open lib/b/b.ts in vscode, type someA
  3. Expected: autoimport suggest import { someA } from '@some/lib-a/a', actual: no autoimport

Example 2

Package 'd' depends only on 'c', 'c' depends on 'a', but 'a' has no index.ts and types in package.json.

Steps to reproduce

  1. clone, switch to no-autoimport-wo-index, yarn install
  2. Open lib/d/d.ts in vscode, type someA
  3. Expected: no someA in autoimport, actual: autoimport suggests broken import { someA } from '../a/a'

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.

Research direction

Clone the linked no-autoimport-wo-index branch, run yarn install, and reproduce both cases in lib/b/b.ts and lib/d/d.ts. Compare the actual and expected autoimport suggestions, including the package.json type declarations, and consider the issue complete when Example 1 suggests @some/lib-a/a while Example 2 does not suggest the broken relative import.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.