🔎 Search Terms
find all references, references, import from keyword, default import, unsaved edit, language server, tsc --lsp, stale results
🕗 Version & Regression Information
- This changed between versions 6.0.3 and 7.0.2: with 6.0.3 (through typescript-language-server 6.0.0) both cases below return the same single location; with 7.0.2 the result depends on the edit.
- Tested with TypeScript 7.0.2 (
tsc --lsp --stdio from the typescript 7.0.2 npm package), macOS 27 on Apple silicon.
- 7.0.2 is still the newest TypeScript 7 release (checked 2026-09-28); reproduces on it again in 3 of 3 runs.
⏯ Playground Link
No response (needs a repository with several tsconfig projects and the language server)
💻 Code
// react-hook-form/react-hook-form at 5fd9ef65290bef2ccaa7ac96dc8d5d55478b5410, dependencies installed with pnpm install
// src/__tests__/logic/getValidateError.test.ts, lines 1 and 2
// (find all references is requested on `from` in line 2, column 15)
import getValidateError from '../../logic/getValidateError';
import noop from '../../utils/noop';
// src/utils/noop.ts
export default function noop() {}
// app/src/form.tsx (app/ has its own tsconfig.json), line 2, edited in the editor and not saved:
import React from 'react'; // before
import React f; // after deleting "rom 'react'"
🙁 Actual behavior
I drive the server over stdio from a small LSP client script and wait for diagnostics to settle after each step. Positions are 0-based LSP positions unless noted.
- Start
tsc --lsp --stdio at the repository root.
- Open
examples/V7/disableNativeValidation.tsx, src/__tests__/logic/getValidateError.test.ts, src/__tests__/logic/skipValidation.test.ts and app/src/form.tsx.
- In
app/src/form.tsx, delete rom 'react' on line 2 (range {line: 1, character: 14} to {line: 1, character: 25}), without saving.
textDocument/references in getValidateError.test.ts at {line: 1, character: 14} (line 2, column 15, the from keyword).
Result: one location, the module specifier '../../utils/noop' on line 2 of the test file. Same in 3 of 3 runs; waiting 60 s before the request did not change it.
🙂 Expected behavior
The same result as a newly started server on the same contents. For that server the edited app/src/form.tsx was saved to disk and not opened, and the other three files were open. It returns 6 locations: the module specifier, the declaration of noop in src/utils/noop.ts, and noop in src/form.tsx lines 7, 39, 45 and 47.
I first saw this with a longer sequence in which line 2 of app/src/form.tsx was typed back and the file closed, and small edits in the other open files were undone, so every file was back to its original text. That session also returned 1 location, and a new server on the unchanged files returned 6.
I'm not sure which of the two answers is intended for from (TypeScript 6.0.3 returns only the module specifier), but the result should not depend on an unsaved edit in a file under app/ that has nothing to do with noop.
Additional information about the issue
The closest reports I found are microsoft/typescript-go#2557 (features on one file going stale until it is reopened) and #2177 (reference counts differing between 6.0 and 7.0); neither has this trigger.
LSP trace
URIs shortened to file:///repo/..., file texts elided; T stands for file:///repo/src/__tests__/logic/getValidateError.test.ts.
--> textDocument/didOpen {"textDocument":{"uri":"file:///repo/examples/V7/disableNativeValidation.tsx","languageId":"typescriptreact","version":1,"text":"..."}}
--> textDocument/didOpen {"textDocument":{"uri":T,"languageId":"typescript","version":1,"text":"..."}}
--> textDocument/didOpen {"textDocument":{"uri":"file:///repo/src/__tests__/logic/skipValidation.test.ts","languageId":"typescript","version":1,"text":"..."}}
--> textDocument/didOpen {"textDocument":{"uri":"file:///repo/app/src/form.tsx","languageId":"typescriptreact","version":1,"text":"..."}}
--> textDocument/didChange {"textDocument":{"uri":"file:///repo/app/src/form.tsx","version":2},"contentChanges":[{"range":{"start":{"line":1,"character":14},"end":{"line":1,"character":25}},"text":""}]}
--> textDocument/references {"textDocument":{"uri":T},"position":{"line":1,"character":14},"context":{"includeDeclaration":true}}
<-- [{"uri":T,"range":{"start":{"line":1,"character":18},"end":{"line":1,"character":34}}}]
A newly started server (app/src/form.tsx edited on disk, not open; the other three files open):
--> textDocument/references {"textDocument":{"uri":T},"position":{"line":1,"character":14},"context":{"includeDeclaration":true}}
<-- [{"uri":T,"range":{"start":{"line":1,"character":18},"end":{"line":1,"character":34}}},
{"uri":"file:///repo/src/utils/noop.ts","range":{"start":{"line":0,"character":24},"end":{"line":0,"character":28}}},
{"uri":"file:///repo/src/form.tsx","range":{"start":{"line":6,"character":7},"end":{"line":6,"character":11}}},
{"uri":"file:///repo/src/form.tsx","range":{"start":{"line":38,"character":15},"end":{"line":38,"character":19}}},
{"uri":"file:///repo/src/form.tsx","range":{"start":{"line":44,"character":14},"end":{"line":44,"character":18}}},
{"uri":"file:///repo/src/form.tsx","range":{"start":{"line":46,"character":16},"end":{"line":46,"character":20}}}]
🔎 Search Terms
find all references, references, import from keyword, default import, unsaved edit, language server, tsc --lsp, stale results
🕗 Version & Regression Information
tsc --lsp --stdiofrom the typescript 7.0.2 npm package), macOS 27 on Apple silicon.⏯ Playground Link
No response (needs a repository with several tsconfig projects and the language server)
💻 Code
🙁 Actual behavior
I drive the server over stdio from a small LSP client script and wait for diagnostics to settle after each step. Positions are 0-based LSP positions unless noted.
tsc --lsp --stdioat the repository root.examples/V7/disableNativeValidation.tsx,src/__tests__/logic/getValidateError.test.ts,src/__tests__/logic/skipValidation.test.tsandapp/src/form.tsx.app/src/form.tsx, deleterom 'react'on line 2 (range{line: 1, character: 14}to{line: 1, character: 25}), without saving.textDocument/referencesingetValidateError.test.tsat{line: 1, character: 14}(line 2, column 15, thefromkeyword).Result: one location, the module specifier
'../../utils/noop'on line 2 of the test file. Same in 3 of 3 runs; waiting 60 s before the request did not change it.🙂 Expected behavior
The same result as a newly started server on the same contents. For that server the edited
app/src/form.tsxwas saved to disk and not opened, and the other three files were open. It returns 6 locations: the module specifier, the declaration ofnoopinsrc/utils/noop.ts, andnoopinsrc/form.tsxlines 7, 39, 45 and 47.I first saw this with a longer sequence in which line 2 of
app/src/form.tsxwas typed back and the file closed, and small edits in the other open files were undone, so every file was back to its original text. That session also returned 1 location, and a new server on the unchanged files returned 6.I'm not sure which of the two answers is intended for
from(TypeScript 6.0.3 returns only the module specifier), but the result should not depend on an unsaved edit in a file underapp/that has nothing to do withnoop.Additional information about the issue
The closest reports I found are microsoft/typescript-go#2557 (features on one file going stale until it is reopened) and #2177 (reference counts differing between 6.0 and 7.0); neither has this trigger.
LSP trace
URIs shortened to
file:///repo/..., file texts elided;Tstands forfile:///repo/src/__tests__/logic/getValidateError.test.ts.A newly started server (
app/src/form.tsxedited on disk, not open; the other three files open):