Skip to content

Monorepo workspace packages in devDependencies are not considered for auto-imports #61709

Closed
@DerGernTod

Description

@DerGernTod

πŸ”Ž Search Terms

"import devDependencies"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about devDependencies

⏯ Playground Link

https://github.com/DerGernTod/typescript-auto-import/tree/main

πŸ’» Code

// file: packages/consumer-dependency/src/dep-consumer.ts
let m: MyInterface;

// file: packages/consumer-dependency/package.json
{
    ...
    "dependencies": {
        "lib": "workspace:*"
    }
}
// file: packages/consumer-dev-dependency/src/dev-consumer.ts
let m: MyInterface;

// file: packages/consumer-dependency/package.json
{
    ...
    "devDependencies": {
        "lib": "workspace:*"
    }
}

// file: packages/lib/src/the-lib.ts
export interface MyInterface {
    foo: string;
}

{
    ...
    "exports": {
        "./the-lib": "./dist/the-lib.js"
    }
}

πŸ™ Actual behavior

Fetching tsc suggestions on let m: MyInterface; in dep-consumer.ts yields the correct Add import from "lib/the-lib".

Fetching tsc suggestions on let m: MyInterface; in dev-consumer.ts yields no result.

πŸ™‚ Expected behavior

Fetching tsc suggestions on let m: MyInterface; in dev-consumer.ts also yields the correct Add import from "lib/the-lib".

Additional information about the issue

Please see the attached reproducer repo. I couldn't figure out a way to build this in TS playground. If there is a way, I'd be glad if someone could enlighten me :)

This might be related to pnpm workspaces imports. While building the reproducer, I started out with npm workspaces and file: dependencies. The behavior was a little different: for the dev dependencies, tsc tried to import from "../../lib/src/the-lib" (which obviously also doesn't work). The import from dependencies also worked fine though. After restarting the language server, once it also worked with "lib/the-lib" but I was never able to get a correct suggestion afterwards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions