File changed on disk with a content-mapped or `.d.ts` extension never triggers workspace/diagnostic/refresh
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, node.js, typescript
- 領域
- backend, devtools, testing-qa
研究方向
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.
由索引模型根據 Issue 內容生成。
描述
🔎 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.
- 主要語言
- Go
- 星號
- 112k
- 分支
- 15.4k
- 平均合併
- 3 天 5 小時
- 30 天內合併 PR
- 149
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/TypeScript 的其他 Issue
-
`tsc --watch` in virtual machine fails with `fanotify_mark on '...' failed: invalid cross-device link` trying to watch parent directories可能已有人在做 @jakebailey 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 62/100
microsoft/TypeScript#65290 ·
維護者通常 1 天內回覆
-
Native API: formatDiagnosticsWithColorAndContext drops related information without a file location可能重新可做 關聯的 PR 已關閉且未合併。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
microsoft/TypeScript#65087 ·
維護者通常 1 天內回覆
-
TS7 LSP: documentHighlight returns nothing when the file path contains '@'可能重新可做 關聯的 PR 已關閉且未合併。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/TypeScript#64758 ·
維護者通常 1 天內回覆
-
Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`可能已有人在做 @rajnish-verma-22172 於 14 天前認領。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 76/100
microsoft/TypeScript#64742 · 1 則留言 ·
維護者通常 1 天內回覆
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmed可能已有人在做 @RyanCavanaugh 於 29 天前認領。 未關閉Bug
難度 2/5 1-3 小時 新手友好度 68/100
microsoft/TypeScript#64618 · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
TUM-Dev/Campus-Backend#678 ·
維護者通常 1 天內回覆
-
fix(app): fail closed if GetGeneralSetting fails during initialization可能已有人在做 @kalavt 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 66/100
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
tsukumogami/tsuku#2813 ·
維護者通常 1 天內回覆
-
component:obi contribfest go test
難度 2/5 1 小時以內 新手友好度 83/100
open-telemetry/opentelemetry-ebpf-instrumentation#4143 · 1 則留言 ·
維護者通常 1 天內回覆