Why GitHub Copilot Stops Suggesting Code in TypeScript Files
🔍 WiseChecker

Why GitHub Copilot Stops Suggesting Code in TypeScript Files

GitHub Copilot stops suggesting code in TypeScript files when the extension loses connection to the language server or when project configuration blocks inline suggestions. This problem commonly occurs after a VS Code update, a change in the TypeScript version used by the project, or when Copilot’s telemetry settings are misconfigured. The root cause is often a mismatch between the TypeScript language service that Copilot relies on and the actual file type or tsconfig settings. This article explains the technical reasons behind the failure and provides step-by-step fixes to restore Copilot suggestions in .ts and .tsx files.

Key Takeaways: Restoring Copilot Suggestions in TypeScript

  • VS Code settings > Extensions > Copilot > Language Server: Ensures the Copilot TypeScript language server is active and not blocked by other extensions.
  • tsconfig.json > include/exclude patterns: Misconfigured file patterns can prevent Copilot from indexing TypeScript files, stopping suggestions.
  • Copilot status bar icon > Enable completions: A single click in the VS Code status bar re-enables inline suggestions if they were manually disabled.

Why Copilot Stops Suggesting in TypeScript Files

GitHub Copilot uses the TypeScript language service to understand the context of your code. When the language service is not running or is incompatible with the project’s TypeScript version, Copilot cannot generate suggestions. This problem often appears after a VS Code update that changes the built-in TypeScript version, or when a project uses a custom tsconfig.json that excludes the current file.

Another common cause is the Copilot extension losing its activation event. The extension activates when it detects a supported file type, but if the language mode of the file is not set to TypeScript or TypeScript React, the extension may not load. This can happen when a file extension is .ts but the language mode has been manually changed to Plain Text or JavaScript.

Network restrictions or proxy settings can also block Copilot’s connection to the GitHub Copilot API. Without a live connection, the extension falls back to a disabled state and stops providing suggestions for all file types, including TypeScript.

TypeScript Language Service Disconnection

Copilot communicates with the TypeScript language service through VS Code’s built-in extension API. If the language service crashes or is disabled by another extension, Copilot cannot retrieve type information or completion context. This results in empty suggestion panels or no inline ghost text.

tsconfig.json Excludes the Current File

When a project’s tsconfig.json uses an include or exclude pattern that does not cover the open file, Copilot may not index that file. The extension relies on the TypeScript project model to understand imports and type definitions. If the file is outside the project scope, Copilot treats it as an untyped JavaScript file and may stop generating TypeScript-specific suggestions.

Steps to Restore Copilot Suggestions in TypeScript Files

Follow these steps in order. After each step, test Copilot by typing a function signature in a .ts file. If suggestions return, you can stop.

  1. Check the Copilot status bar icon
    Look at the bottom-right corner of VS Code. The Copilot icon shows a circle with a checkmark when active, or a circle with a line through it when disabled. Click the icon and select Enable completions. This re-enables inline suggestions if they were turned off manually.
  2. Verify the file language mode
    Click the language mode indicator in the bottom-right status bar (e.g., TypeScript or JavaScript). Ensure it is set to TypeScript or TypeScript React for .tsx files. If it shows Plain Text or another mode, select TypeScript from the dropdown. Copilot only activates for supported language modes.
  3. Reload the TypeScript language service
    Open the Command Palette with Ctrl+Shift+P. Type TypeScript: Restart TS server and press Enter. This restarts the language service and forces Copilot to re-register its listeners. After the restart, type a few lines to see if suggestions appear.
  4. Check tsconfig.json include/exclude patterns
    Open your project’s tsconfig.json. Look for the include and exclude arrays. If the current file’s path does not match any include pattern, add it. For example, if your file is src/components/Button.ts and include is [“src//ts”], it should be covered. If exclude contains the file’s folder, remove it. Save the file and restart the TS server.
  5. Disable conflicting extensions
    Some extensions like ESLint, Prettier, or older Copilot versions can interfere. Open the Extensions panel with Ctrl+Shift+X. Disable all extensions except GitHub Copilot and GitHub Copilot Chat. Reload the VS Code window. If suggestions return, enable extensions one by one to find the conflict.
  6. Update or reinstall GitHub Copilot
    Open the Extensions panel, find GitHub Copilot, and click the gear icon. Select Install Another Version and pick the latest stable release. If you already have the latest, click Uninstall, then restart VS Code and reinstall from the marketplace.
  7. Check network connectivity
    Open the VS Code terminal and run curl -I https://api.githubcopilot.com. If you get a timeout or connection refused, your network may block Copilot. Contact your IT department to allow traffic to api.githubcopilot.com and all subdomains. You can also set a proxy in VS Code settings under Http: Proxy.

If Copilot Still Has Issues After the Main Fix

Even after following the steps above, some users encounter persistent problems. Below are the most common remaining issues and how to resolve them.

Copilot Suggests JavaScript Instead of TypeScript

This happens when the file is not recognized as TypeScript by the language service. Open the Command Palette and run Developer: Inspect Editor Tokens and Scopes. Check that the language scope includes source.ts. If it shows source.js, the file language mode is wrong. Reassign it to TypeScript using the status bar method described in step 2.

Copilot Works in .js Files but Not in .ts Files

This indicates a TypeScript-specific configuration issue. Open tsconfig.json and ensure compilerOptions.allowJs is not set to false if you have mixed file types. Also verify that the file is not excluded by a parent tsconfig.json in a monorepo setup. Run tsc –showConfig in the terminal to see the effective configuration.

Copilot Suggestions Are Very Slow or Incomplete

Slow suggestions often point to a large project with many files. Copilot indexes the entire workspace. Open VS Code settings and search for github.copilot.editor.enableAutoCompletions. Set it to false, then back to true to reset the suggestion engine. You can also reduce the suggestion delay by setting github.copilot.editor.suggestionDelay to 0.

Copilot Active vs Copilot Disabled: Key Differences

Item Copilot Active Copilot Disabled
Inline ghost text Appears as you type No ghost text shown
Status bar icon Circle with checkmark Circle with line
Language service connection Connected to TS server Not connected
tsconfig.json dependency File must be included No dependency
Network requirement Must reach api.githubcopilot.com Not required

You can now diagnose and fix the three most common reasons Copilot stops suggesting code in TypeScript files: language service disconnection, tsconfig exclusion, and disabled completions. Start by checking the status bar icon and the file language mode. If the problem persists, restart the TypeScript server and review your tsconfig.json patterns. For advanced troubleshooting, disable conflicting extensions and verify network access to the Copilot API. To prevent future interruptions, pin your VS Code TypeScript version in settings with the typescript.tsdk option.