Skip to content

[Bug?]: node_modules/.bin/tsc not linked to the correct package when ts7 and ts6 are installed using aliases #7215

Description

@robrichard

Self-service

  • I'd be willing to implement a fix

Describe the bug

The typescript docs recommend installing typescript v6 and v7 side by side for compatibility using aliases. See docs: https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6.0

{
  "name": "yarn-ts7",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "packageManager": "yarn@4.17.1",
  "devDependencies": {
    "@typescript/native": "npm:typescript@~7.0.2",
    "typescript": "npm:@typescript/typescript6@~6.0.2"
  }
}

When installing as directed using the above package.json and nodeLinker: node-modules, node_modules/.bin/tsc is linked to the @typescript/old package. This should not happen since @typescript/old is a transitive dependency. Instead it should link to the @typescript/native that is declared in the package.json.

To reproduce

Minimal reproduction in this repo: https://github.com/robrichard/yarn-ts7/tree/main

Environment

System:
    OS: macOS 26.5.1
    CPU: (15) arm64 Apple M5 Pro
  Binaries:
    Node: 24.18.0 - /private/var/folders/6z/sjjqqggd2qs3wxymlbry_twc0000gn/T/xfs-673a7ecc/node
    Yarn: 4.17.1 - /private/var/folders/6z/sjjqqggd2qs3wxymlbry_twc0000gn/T/xfs-673a7ecc/yarn
    npm: 11.16.0 - /usr/local/bin/npm

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions