TypeScript Workspace Plugin

2.0.1 · active · verified Sun Apr 19

typescript-workspace-plugin is a language service plugin for TypeScript that adds robust support for monorepo setups, specifically those using Yarn-like workspaces. It allows individual packages within a workspace to maintain independent `tsconfig.json` files while enabling the TypeScript language service to correctly resolve local package sources, rather than relying solely on `node_modules` typings. This restores critical IDE features such as 'go to definition,' 'find references,' and accurate type checking across locally linked dependencies. The current stable version is 2.0.1. Its release cadence is irregular, driven by community needs and TypeScript updates. A key differentiator is its ability to maintain independent package configuration while ensuring full language service functionality within a monorepo, addressing a common pain point for developers working with interwoven local packages.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the essential configuration for integrating the typescript-workspace-plugin into a monorepo. It shows how to add the plugin entry to individual package `tsconfig.json` files and define the `workspace-sources` mapping in the top-level `package.json` to enable correct language service resolution across workspace packages.

/* tsconfig.json for an individual package */
{
  "extends": "../../tsconfig.base.json", // Example extend
  "compilerOptions": {
    "outDir": "./lib",
    "rootDir": "./src"
  },
  "plugins": [
    {"name": "typescript-workspace-plugin"}
  ],
  "include": ["src"]
}

/* Top-level package.json for the monorepo root */
{
  "name": "my-monorepo",
  "version": "1.0.0",
  "private": true,
  "workspaces": [
    "packages/*",
    "apps/*"
  ],
  "workspace-sources": {
    "*": ["packages/*/src", "apps/*/src"]
  },
  "devDependencies": {
    "typescript": "^4.9.5", // Ensure compatible TS version
    "typescript-workspace-plugin": "^2.0.0"
  }
}

view raw JSON →