You hit save on a TypeScript file in a multi-package monorepo and wait three seconds for autocompletion to pop up. You type a function name, wait another four seconds for the import suggestion, and your laptop fan ramps up while a Node process named tsserver.js pins a CPU core at 100 percent.

The symptom: sluggish TSServer and unindexed workspaces

When VS Code opens a large repository or a multi-root workspace, its TypeScript extension runs one or more language server processes in the background. If your project contains multiple tsconfig.json files, hundreds of packages, or deep nested node_modules, the default configuration wastes cycles reading files it never needs to touch. Inlay hints make this worse by forcing full AST evaluations on every keystroke.

The built-in command palette shows the damage quickly. If you run TypeScript: Open TS Server Log and inspect the output, you often see lines like this:

text
[11:04:12.183] Watched files limit exceeded or processing large directory structure
[11:04:13.204] DirectoryWatcher:: Added:: Path: /workspace/packages/api/dist/index.d.ts
[11:04:13.205] DirectoryWatcher:: Added:: Path: /workspace/packages/web/.next/types.d.ts
[11:04:14.412] [perf] getErrForProject: Took 3840ms
[11:04:18.991] Info: Synchronizing a large number of file changes: 14210 files

Under the hood, VS Code spawns tsserver with a memory ceiling that is often too small for massive AST graphs, causing constant garbage collection. Worse, TSServer sets up recursive watchers on build directories (dist, .next, build) and tries to parse emitted declaration files alongside your raw source files. When you add TypeScript inlay hints to the mix, VS Code continually queries the server for parameter names, return types, and variable types for all code visible in your active viewport.

Here is how to rein in the language server, configure multi-root project boundaries, and trim inlay hints down to what you actually need.

Isolate project references in tsconfig.json

Before changing VS Code settings, ensure your TypeScript configuration does not force the compiler to traverse your entire repo as a single monolith. When packages import each other through source files rather than built definitions, TSServer builds one massive program graph.

In a monorepo setup, turn on project references. Split each package into its own project boundary.

Root tsconfig.json:

json
{
  "compilerOptions": {
    "composite": true,
    "declaration": true,
    "declarationMap": true
  },
  "files": [],
  "references": [
    { "path": "./packages/core" },
    { "path": "./packages/api" },
    { "path": "./packages/web" }
  ]
}

Package-level packages/api/tsconfig.json:

json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "outDir": "./dist",
    "rootDir": "./src",
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "skipLibCheck": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"],
  "references": [
    { "path": "../core" }
  ]
}

skipLibCheck: true stops the compiler from type-checking all declaration files across every package in node_modules. If your dependencies have conflicting or poorly typed .d.ts files, this single flag shaves whole seconds off server boot times.

Tune VS Code settings for multi-root workspaces

If you work in a multi-root workspace (using a .code-workspace file), VS Code can run a dedicated TSServer instance per folder, or it can run one shared instance. By default, it runs one instance, which gets bogged down if one project is huge and another is small.

Configure your .code-workspace file or .vscode/settings.json to prevent the file watcher from eating memory, increase the Node.js memory ceiling for TSServer, and constrain the file watcher.

json
{
  "folders": [
    {
      "name": "Core Engine",
      "path": "packages/core"
    },
    {
      "name": "API Service",
      "path": "packages/api"
    },
    {
      "name": "Web Client",
      "path": "packages/web"
    }
  ],
  "settings": {
    "typescript.tsserver.maxTsServerMemory": 4096,
    "typescript.tsserver.experimental.enableProjectDiagnostics": false,
    "typescript.disableAutomaticTypeAcquisition": true,
    "typescript.preferences.includePackageJsonAutoImports": "auto",
    
    "files.watcherExclude": {
      "**/.git/objects/**": true,
      "**/.git/subtree-cache/**": true,
      "**/node_modules/**": true,
      "**/dist/**": true,
      "**/build/**": true,
      "**/.next/**": true,
      "**/coverage/**": true
    },
    "search.exclude": {
      "**/node_modules": true,
      "**/dist": true,
      "**/build": true,
      "**/.next": true
    }
  }
}

Setting typescript.tsserver.maxTsServerMemory to 4096 prevents Node from thrashing its garbage collector when the heap approaches the default 1.4 GB limit.

Setting typescript.tsserver.experimental.enableProjectDiagnostics to false is critical. When enabled, TSServer runs type-checking across your entire project in the background every time you touch a file. With it off, it only type-checks the files you currently have open in tabs.

Prune inlay hints to essential paths

Inlay hints are expensive. Every time you scroll, edit, or split an editor, VS Code asks the TypeScript compiler: “What are the inferred types of all variables, function returns, and parameter labels in this viewport?”

If you have all inlay hints turned on, code like this causes continuous queries:

typescript
// All hints active: parameter names, variable types, function returns
export const processPayload = async (payload: RequestPayload) => {
  const result = await database.users.findMany({
    where: { active: true },
    select: { id: true, email: true, profile: true }
  });
  
  return result.map(user => ({
    userId: user.id,
    display: `${user.profile.firstName} ${user.profile.lastName}`
  }));
};

To keep completions fast without abandoning hints completely, turn off parameter names and variable types, and leave only return types or specific literals. Or better yet, switch inlay hints to show only when holding down a shortcut key.

Add these entries to your .vscode/settings.json:

json
{
  "editor.inlayHints.enabled": "offUnlessPressed",
  "typescript.inlayHints.parameterNames.enabled": "none",
  "typescript.inlayHints.variableTypes.enabled": false,
  "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
  "typescript.inlayHints.propertyDeclarationTypes.enabled": false,
  "typescript.inlayHints.enumMemberValues.enabled": true
}

With "editor.inlayHints.enabled": "offUnlessPressed", the hints disappear during normal typing and editing. The language server does zero layout work for hints. When you want to inspect types or parameter labels, press Ctrl+Alt (or Cmd+Option on macOS), and the hints render immediately for that brief moment.

Edge case 1: The dual-server trap with workspace versions

A common trap in multi-root workspaces is having different TypeScript versions installed across packages. If packages/api has [email protected] and packages/web has [email protected], VS Code might try to negotiate which binary to load, or fall back to its internal bundled version.

Check which TypeScript binary VS Code uses by opening any .ts file and clicking the TypeScript version number in the status bar at the bottom right, or running TypeScript: Select TypeScript Version... in the command palette.

Select:

text
Use Workspace Version (node_modules/typescript/lib)

To lock this down consistently across developers and prevent the editor from falling back to its internal compiler, set this in .vscode/settings.json:

json
{
  "typescript.tsdk": "node_modules/typescript/lib"
}

If your monorepo keeps TypeScript hoisted at the root, point directly to the root location:

json
{
  "typescript.tsdk": "./node_modules/typescript/lib"
}

If you do not set this, VS Code often defaults to its internal version on fresh clones. If the bundled version differs from your project dependencies, you will get phantom errors that do not appear during terminal builds.

Edge case 2: Auto-imports scanning out-of-scope node_modules

When you use pnpm or npm workspaces, packages are often symlinked into nested node_modules directories. TSServer tries to provide auto-imports for every module in your dependency tree. If it recursively crawls every package inside a monorepo symlink cycle, completion menus freeze.

Control auto-import indexing directly in .vscode/settings.json:

json
{
  "typescript.preferences.includePackageJsonAutoImports": "on",
  "typescript.preferences.autoImportFileExcludePatterns": [
    "**/node_modules/@types/react/global.d.ts",
    "**/dist/**",
    "**/.next/**"
  ]
}

Setting includePackageJsonAutoImports to "auto" tells TSServer to only suggest imports from packages explicitly declared in your package.json dependencies rather than everything present anywhere on disk.

Verifying the performance fix

To verify that your configuration changes actually reduced server latency, test TSServer directly using its performance tracing features.

Open your command palette (Ctrl+Shift+P or Cmd+Shift+P) and run:

text
TypeScript: Open TS Server Log

If the option is disabled, enable logging first in your settings:

json
{
  "typescript.tsserver.log": "verbose"
}

Reload the window. Open a large file and trigger an auto-complete request by typing an empty space and pressing Ctrl+Space. Now open the log file. Look for the quickinfo or completions request IDs:

text
[11:22:04.102] request: completions (32)
{"file":"/workspace/packages/api/src/server.ts","line":42,"offset":18}
[11:22:04.148] response: completions (32) 46ms

A healthy server should respond to completions in under 100 milliseconds. If the response time is over 1000 milliseconds, look higher in the log for Project: /workspace/packages/api/tsconfig.json. Check the Files count. If that count is in the thousands for a package that only contains thirty source files, an unexcluded directory or an un-referenced project import is dragging third-party code into your AST.

Once verified, set "typescript.tsserver.log": "off" so the server does not waste I/O cycles writing mega-bytes of debug logs to your drive.

More in TypeScript