Skip to content

[FEATURE]: LSP support for TypeScript monorepos #16335

Closed as not planned
Closed as not planned

Description

@OverHash

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

TypeScript monorepos currently do not activate the TypeScript LSP.

Currently, OpenCode uses

export const Typescript: Info = {
id: "typescript",
root: NearestRoot(
["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"],
["deno.json", "deno.jsonc"],
),
extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"],
async spawn(root) {
const tsserver = await Bun.resolve("typescript/lib/tsserver.js", Instance.directory).catch(() => {})
log.info("typescript server", { tsserver })
if (!tsserver) return
const proc = spawn(BunProc.which(), ["x", "typescript-language-server", "--stdio"], {
cwd: root,
env: {
...process.env,
BUN_BE_BUN: "1",
},
})
return {
process: proc,
initialization: {
tsserver: {
path: tsserver,
},
},
}
},
}
as the reference impl for activating the TypeScript LSP. This is not context aware of TypeScript monorepos.

In a monorepo where the TypeScript workspace lives one level lower, TypeScript LSP does not activate. It is common to be running OpenCode sessions in the root, so that the agent will access the different workspace members.

Example Scenario

In my case, the repository root is a pnpm workspace, but the TypeScript projects live in child packages rather than at the repo root.
Workspace layout:

/
├── package.json
├── pnpm-workspace.yaml
├── node_modules
│   └── .pnpm
│       └── [email protected]
│           └── node_modules
│               └── typescript
├── client
│   ├── package.json
│   ├── tsconfig.json
│   └── node_modules
│       ├── typescript -> ../../node_modules/.pnpm/[email protected]/node_modules/typescript
│       └── .bin
│           └── tsc
└── server
    ├── package.json
    ├── tsconfig.json
    └── node_modules
        ├── typescript -> ../../node_modules/.pnpm/[email protected]/node_modules/typescript
        └── .bin
            └── tsc

pnpm-workspace.yaml:

packages:
  - "client"
  - "server"

While repo root has a package.json and a node_modules/, there is no dependencies in the package.json (and hence does not have a node_modules/typescript).

Observed package setup:

  • client/package.json has typescript in devDependencies
  • server/package.json has typescript in devDependencies
  • client/tsconfig.json exists
  • server/tsconfig.json exists
    Actual symlink resolution in this repo:
    client/node_modules/typescript -> ../../node_modules/.pnpm/[email protected]/node_modules/typescript
    server/node_modules/typescript -> ../../node_modules/.pnpm/[email protected]/node_modules/typescript

If possible, OpenCode should somehow support the TypeScript LSP. For example, reading any file that is part of the pnpm workspace, which has a TypeScript dependency in that project, could trigger the LSP activation for that file.

References

See #8712 which briefly describes the scenario in which OpenCode fails to run the TypeScript LSP

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Mar 6, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 6, 2026
  3. github-actions commented on Mar 6, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • [FEATURE]: Force LSP usage #8712: Very similar request - TypeScript LSP not activating in monorepos where the TypeScript workspace lives one level below the repo root (same scenario described here)

    In fact, this issue already references #8712 in its description. Consider whether your request can be addressed by or combined with that existing issue.

  4. OverHash commented on Mar 6, 2026

    @OverHash
    Author

    This feature is related, but not the same as that issue. This issue is not focused around forcing LSP usage, it is more general and would like automatic LSP detection and activation (which is much more convenient than forcing LSP usage).

  5. OverHash commented on Mar 6, 2026

    @OverHash
    Author

    Ugh, looks like this is a duplicate of #7690.. I did look :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions