microsoft / microsoft/TypeScript

TypeScript language server fails to recognize new files and needs restart

Open
#60,040 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Type: Bug

Since the last update(s) or so, the TypeScript language server fails to recognize or do any code completion on newly created (or copy-pasted) files, no matter if they are TS or TSX.

With TS files it fails to do code completion for any other code from my project (cannot find anything from my project to import when I do CTRL+SPACE).

For TSX files, it fails to recognize React and all I get is syntax errors for JSX code.

I have to manually restart the TS language server in order to fix this. That or wait ~5s.

Context:

  • I am on the latest TS version 5.5.4
  • I am working on a typical NextJS (14.2.5) project with shadcn-ui components.
    tsconfig is the nextj's default:
{
  "compilerOptions": {
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "target": "ES2020",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules", ".next"]
}

VS Code version: Code 1.92.1 (Universal) (eaa41d57266683296de7d118f574d0c2652e1fc4, 2024-08-07T20:16:39.455Z)
OS version: Darwin arm64 23.5.0
Modes:

System Info
Item Value
CPUs Apple M1 Max (10 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 32.00GB (1.05GB free)
Process Argv --crash-reporter-id 593ea142-22bd-42ca-a19a-94f980be787b
Screen Reader no
VM 0%
Extensions (37)
Extension Author (truncated) Version
rust-bundle 1Yi 1.0.0
html-class-suggestions And 1.2.1
biome bio 2.3.0
vscode-tailwindcss bra 0.12.6
npm-intellisense chr 1.4.5
path-intellisense chr 2.9.0
vscode-css-modules cli 0.5.1
vscode-notes dio 1.2.1
rust-syntax dus 0.6.1
prettier-vscode esb 10.4.0
html-slim-scss-css-class-completion gen 1.7.8
codespaces Git 1.17.2
copilot Git 1.221.0
copilot-chat Git 0.18.1
vscode-github-actions git 0.26.3
vscode-scss mrm 0.10.0
black-formatter ms- 2024.2.0
debugpy ms- 2024.10.0
python ms- 2024.12.2
vscode-pylance ms- 2024.8.1
jupyter ms- 2024.7.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.19
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
live-server ms- 0.4.14
vscode-speech ms- 0.10.0
material-icon-theme PKi 5.9.0
vscode-css-peek pra 4.4.1
code-snapshot rob 0.2.1
rust-analyzer rus 0.3.2062
tauri-vscode tau 0.2.6
luna-paint Tyr 0.16.0
vscode-mdx uni 1.8.9
vscode-wakatime Wak 24.6.0
pretty-ts-errors Yoa 0.6.0
vscode-className-completion zwk 0.0.18
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
da93g388:31013173
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
impr_priority:31102340
refactort:31108082
pythonrstrctxt:31112756
wkspc-onlycs-t:31111718
wkspc-ranged-t:31111713

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the reported Next.js project setup by creating or copying new TS and TSX files, then test completion and React recognition before and after restarting the TypeScript language server. Trace the language-server handling of newly created files; done means project imports, React, and JSX are recognized without a manual restart or unexplained delay.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.