File changed on disk with a content-mapped or `.d.ts` extension never triggers workspace/diagnostic/refresh
Maintainer thường phản hồi trong vòng 1 ngày
Đá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.DidChangeWatchedFilesfrom taking everything after the last dot topath.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:
- dep.ts changed on disk, refresh requests: 1
- shape.data changed on disk, refresh requests: 0
errors when pulled by hand: [] - 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
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.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/TypeScript
-
Won't Fix
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
microsoft/TypeScript#65107 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Native API: formatDiagnosticsWithColorAndContext drops related information without a file locationCó thể đã có người làm @timurzvural đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/TypeScript#65087 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64758 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`Có thể đã có người làm @rajnish-verma-22172 đã nhận 13 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#64742 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsCó thể đã có người làm @dmety đã nhận 26 ngày trước. Đang mởBug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/TypeScript#64661 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
hyperledger/fabric-x-orderer#1409 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Azure/typespec-azure#5936 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
-
Fix mode unpins a reusable workflow call when the same repository is also used as a step actionĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
github/gh-actions-lock#261 ·
Maintainer thường phản hồi trong vòng 1 ngày