You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed in our scripts dir (no tsconfig), that clicking on a file flashed errors. I closed it, opened another file, and the errors appeared and disappeared again! If I opened another file without closing the first, that one was fine.
The issue is that we lose the ATA state when inferred projects go away, so reopening causes ATA to happen again.
Save the state and apply it directly to inferred projects if present.
Invalidate ATA cache when inferred-project options change
tsc/internal/project/project.go:214
Root names and contents are not the complete ATA input. If inferred-project compiler options change while no inferred project exists, the cached state is left untouched; reopening the same roots applies typings computed under the old options before ATA is queued in the background (and resolution-affecting options can also change the unresolved-import set). Preserve and compare the relevant command-line/mapping inputs, or invalidate this cache when those inputs change.
An inferred project can exist without a program while cached ATA state is still authoritative. Keep that state and its watcher until a built program validates it, and reject results older than the latest installed or confirmed state.
Typings cache writes are outputs of acquisition, not discovery changes, and can arrive in the same flush as their result. Keep those events available to the program while excluding them from ATA invalidation, without losing real package-owned inputs or full invalidations.
Installed packages can change their declaration entry points without a
version change or deletion of the old file. Preserve package identities
so active and dormant projects reject obsolete typings without treating
an install’s own cache writes as stale discovery inputs.
Equivalent loose files should retain acquired typings without restoring
results made obsolete while no inferred project exists. Compare effective
discovery inputs and revalidate installation demand before acceptance.
Directory deletion notifications must also invalidate ATA-only manifests
that are not represented in the compiler file cache.
This maps and concatenates the same watch list for every changed, created, or deleted URI. Because the helper runs for each project during snapshot updates, large unrelated event batches repeatedly allocate and copy the entire list even when nothing matches. Build the combined slice once outside affectsWatch, and compute fileNameKey once per event rather than once per watched path.
Unrelated event batches should not rebuild the same discovery watch list
for every notification. Bound watch-list allocations per batch while
preserving ancestor deletion handling.
Resolve only demanded packages during ATA requests
tsc/internal/project/ata/ata.go:192
Each ATA request creates a fresh resolver and resolves every package in the shared typings cache before determining this project's demand. As that cache accumulates packages from other projects, even a request needing one package performs module-resolution and filesystem work for all cached packages. Resolve only demanded names, while retaining the fresh entry-point check for those names so package metadata changes are still detected.
Scoped dependencies are discovered as @a/b, but the cache and registry use a__b. This new membership check omits an already-installed scoped dependency from cachedTypingPaths, while filterTypings skips reinstalling it because the mangled cache entry is current. Subsequent ATA results therefore lose its typings. Iterate the demanded names, use module.MangleScopedPackageName for cache and registry lookups, and update the original discovery key. Add a regression test with a cached scoped dependency.
Avoid repeated dependency discovery while holding snapshotMu
IsCurrent repeats the filesystem discovery already performed in the background, including dependency-manifest parsing and, when no dependencies are listed, traversal of node_modules. Here it runs inside Snapshot.Clone while Session.updateSnapshot holds snapshotMu. Large dependency trees therefore add synchronous filesystem work to file-open and language-service requests and block snapshot readers. Track discovery inputs and their invalidation generation so results can be checked here without repeating full discovery under the lock.
ATA requests should scale with the project's demand, not the size of the
shared typings cache or dependency trees traversed again under the
snapshot lock. Scoped dependencies must retain their cached typings
across subsequent acquisitions.
Keep discovery in the background and establish provisional watch coverage
before dispatch. Reject results whose coverage was discarded or whose
package-owned declaration availability changed during installation.
These comparisons miss real-path events for symlinked discovery packages. For example, let /workspace/node_modules/foo point to /vendor/foo, with foo discovered from dependencies but not imported by the program. After closing the last file, changing /vendor/foo/package.json to provide its own typings does not match the saved /workspace/node_modules watch input. Discovery reads the manifest through request.FS, so snapshot alias expansion need not cover it. Reopening can therefore restore obsolete @types/foo roots and skip discovery. Retain both lexical and real paths for discovered manifests/packages, use them for watch registration and invalidation, and add a regression test for a manifest change while the inferred project is inactive.
Discovery can read symlinked dependency manifests that never enter the
compiler host's alias cache. Real-path changes must invalidate ATA even
when its project is closed or its first installation is still pending.
Coverage must be established before discovery reads, not merely when
installation finishes. Shared watch references are not proof of client
registration, so watch deltas also need snapshot-ordered acknowledgement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed in our scripts dir (no tsconfig), that clicking on a file flashed errors. I closed it, opened another file, and the errors appeared and disappeared again! If I opened another file without closing the first, that one was fine.
The issue is that we lose the ATA state when inferred projects go away, so reopening causes ATA to happen again.
Save the state and apply it directly to inferred projects if present.