Skip to content

Wrong import suggestions for relative files #26047

Closed

Description

For some unknown reason, I'm getting wrong suggested imports in a certain scenario. I'm working in a mono repo with yarn workspaces. I have a package that depends on another package from the monorepo. The package I'm depending on (package-a) has a export from the main file. In the other package (package-b) I have a file that imports from package-a. But then when I'm trying to do an import from two relative files in package-b I'm getting a wrong import (like shown). But when I remove the import from package-a from the file in package-b I'm getting the correct import suggestion.

TypeScript Version: 3.1.0-dev.20180728

Search Terms:
wrong import suggestion
no relative import suggestion

Code

A link to a github repo with a reproduction

Steps to reproduce:

  1. git clone and yarn
  2. run yarn build inside packages/package-a
  3. open vscode and navigate to packages/package-b/src/another.ts.
  4. open the import suggestion for C. Wrong import is shown.
  5. Go to file packages/package-b/src/index.ts
  6. Comment the first line (the import)
  7. Go to file packages/package-b/src/another.ts
  8. Open the import suggestion. correct import is shown

Expected behavior:

Suggest import on a file trying to import from another relative file should be:
screen shot 2018-07-29 at 4 02 39 pm

Actual behavior:

Instead the import is suggested with the name of module and the src folder
screen shot 2018-07-29 at 4 06 57 pm

Activity

  1. netanelgilad commented on Jul 29, 2018

    @netanelgilad
    Author

    Duplicate of #26044. I'l add a comment about my scenario there.

  2. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions