File changed on disk with a content-mapped or `.d.ts` extension never triggers workspace/diagnostic/refresh

Đang mở
#64,943 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mrlubos đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #64944 của @mrlubos — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, node.js, typescript
Lĩnh vực
backend, devtools, testing-qa

Hướng nghiên cứu

Start with the change in #64159 and trace Session.DidChangeWatchedFiles, path.Extension(), and the content mapper extension check described in the issue. Use the linked repro repository with npm install && npm run repro to compare changes to dep.ts, shape.data, and an open shape.data file. Done when disk changes to mapped files and .d.ts files trigger diagnostic refreshes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

🔎 Search Terms

"content mapper", "contentMappers", "workspace/diagnostic/refresh", "didChangeWatchedFiles", "isRelevantExtension", "stale diagnostics", "restart TS server", ".d.ts"

🕗 Version & Regression Information
  • This changed in #64159, which switched Session.DidChangeWatchedFiles from taking everything after the last dot to path.Extension(). Seen on [email protected].
⏯ Playground Link

No response

💻 Code

Repro: https://github.com/mrlubos/ts-content-mapper-refresh (npm install && npm run repro)

// tsconfig.json
{ "compilerOptions": { "module": "nodenext", "strict": true, "noEmit": true },
  "contentMappers": [{ "package": "toy-mapper", "extensions": [".data"] }] }
// index.ts. toy-mapper turns each `name: type` line of shape.data into a member of `Data`.
import type { Dep } from './dep.js';
import type { Data } from './shape.data';
declare const dep: Dep;
declare const data: Data;
export const fromTs = dep.age;     // error until `age` is added to dep.ts
export const fromData = data.age;  // error until `age: number` is added to shape.data
🙁 Actual behavior

After shape.data changes on disk (written by another process, with the editor sending workspace/didChangeWatchedFiles), the server never sends workspace/diagnostic/refresh. In VS Code the error on data.age stays until "TypeScript: Restart TS Server". The server already has the right answer: a textDocument/diagnostic request made by hand returns no errors. npm run repro drives tsc --lsp as VS Code does and prints:

  1. dep.ts changed on disk, refresh requests: 1
  2. shape.data changed on disk, refresh requests: 0
    errors when pulled by hand: []
  3. shape.data edited while open, refresh requests: 1
🙂 Expected behavior

A change on disk to a file a registered content mapper handles should refresh diagnostics the way a change to a .ts file does, since it changes the program. This matters most when a tool regenerates the mapped file, for example a dev server writing an API description on each reload, because the editor never has that file open.

Additional information about the issue

path.Extension() returns only the extensions TypeScript reads itself. For shape.data it returns "", so the path is treated as a possible directory: DirectoryExists is false and the change is dropped. The check against the extensions a project's contentMappers register is in the else branch, which a mapped extension never reaches.

The same change breaks .d.ts files: path.Extension() returns .d.ts, which isRelevantExtension does not list, so a declaration file changed on disk does not refresh diagnostics either.

A workaround for mapped files is to keep the file open in an editor tab, so VS Code reloads it and sends didChange.

Ngôn ngữ chính
Go
Star
112k
Fork
15.4k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
126

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/TypeScript

Tất cả issue của microsoft/TypeScript

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.