Skip to content

Fix transpileModule/transpileDeclaration bugs - #64024

Merged
Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:transpile-module-bugs
Aug 26, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
microsoft:mainfrom
andrewbranch:transpile-module-bugs

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

Thanks John Reilly (@johnnyreilly) for the bug reports!

Prevent isolatedDeclarations from producing a spurious option diagnostic during JavaScript transpilation and support declaration transpilation with Windows absolute paths.\n\nCo-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 25, 2026 23:39
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes transpilation diagnostics and eliminates unintended module-resolution filesystem access.

Changes:

  • Ignores isolatedDeclarations during JavaScript transpilation.
  • Adds a program mode that skips module, type-reference, library-replacement, and package metadata resolution.
  • Adds compiler and sync/async API regression coverage.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tsc/internal/transpile/transpile.go Applies transpile overrides and disables resolution.
tsc/internal/transpile/fs.go Rejects unexpected filesystem access.
tsc/internal/transpile/fs_test.go Tests rejected filesystem operations.
tsc/internal/compiler/program.go Adds the resolution-skipping option.
tsc/internal/compiler/filesparser.go Skips reference and library resolution.
tsc/internal/compiler/fileloader.go Bypasses remaining resolver paths.
tsc/testdata/tests/cases/transpile/syntheticImports.tsx Tests synthetic helper imports.
tsc/testdata/tests/cases/transpile/noModuleResolution.ts Tests resolver-free transpilation.
tsc/testdata/baselines/reference/transpile/syntheticImports.js Records synthetic-import emit.
tsc/testdata/baselines/reference/transpile/noModuleResolution.js Records JavaScript emit without resolution.
tsc/testdata/baselines/reference/transpile/noModuleResolution.d.ts Records declaration emit without resolution.
packages/typescript/test/sync/api.test.ts Adds synchronous API regressions.
packages/typescript/test/async/api.test.ts Adds asynchronous API regressions.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Aug 26, 2026
@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Aug 26, 2026
Merged via the queue into microsoft:main with commit 5739027 Aug 26, 2026
25 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the transpile-module-bugs branch August 26, 2026 01:40
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Aug 26, 2026
@johnnyreilly

Copy link
Copy Markdown

Nice work Andrew Branch (@andrewbranch)! I'll see if I can try this out on TypeStrong/ts-loader#1704 this weekend. Thanks!

@johnnyreilly

John Reilly (johnnyreilly) commented Aug 29, 2026 •

Copy link
Copy Markdown

I was able to remove workarounds from ts-loader after this landed. See TypeStrong/ts-loader@6146ee1 and TypeStrong/ts-loader@38d364e

Thanks Andrew Branch (@andrewbranch)!

John Reilly (johnnyreilly) added a commit to TypeStrong/ts-loader that referenced this pull request Oct 22, 2026
* feat: add tsgo transpile path

* fix: load tsgo API via ESM import

* Restrict execution-test TS matrix to tsgo version

* chore: explicitly use [email protected]

* Port build to TypeScript 7 native API

* fix: large

* fix native API execution test defaults

* chore: remove test

* fix: remove unused

* fix: happify ashley

* fix: use TS7 API in comparison test harness

* fix: getProgram

* feat: extra diagnostics

* feat: match existing formatting

* chore: regenerate yarn.lock

* chore: remove happypack

* fix: aliasResolution

* chore: bump version

* fix: colors

* fix: webpack 4

* chore: rename

* chore: remove unused

* fix: rootDir in tests

* fix: outputs

* fix: declarationOutput

* fix: declaration tests

* fix: dependency

* fix: output

* fix: declarationWathc

* chore: upgrade prettier

* fix: reportFiels

* fix: test

* fix: onlyCompileBundledFiles

* fix: style

* fix: otherLoadersWatch

* feat: settings.json

* fix: output

* chore: add setings

* fix: resolveJsonModule

* fix: tsconfileInvalid

* fix: tsconfileInvalidFile

* revert last fix

* Comment out DIAGNOSTIC_CODE_FILE_NOT_FOUND constant

Comment out the DIAGNOSTIC_CODE_FILE_NOT_FOUND constant.

* chore: skip test

* fix: yarn comparison-tests --single-test nodeModulesMeaningfulErrorWhenImportingTs

* fix: output

* chore: temp files better

* feat: virtual file system

* fix:  sourceMapsShouldConsiderInputSourceMap

* fix: allow spike rm

* fix: Windows comparison-test failures in the tsgo API backend

program.getSourceFileNames()/getConfigFileNames() and related lookups
return the TypeScript API's forward-slash-normalized paths, but several
call sites handed those straight to Node's OS-native `path` functions or
to webpack's addDependency/addBuildDependency (which reject non-native
absolute paths on Windows). This surfaced as a cluster of Windows-only
comparison-test failures with no macOS/Linux equivalent:

- getDirectResolvedImports/resolveRelativeSpecifier: dependant-recheck
  lookups failing (dependencyErrors)
- findTransitiveDependants: multi-hop BFS matching failing
  (simpleDependency)
- ensureSyntheticConfigForFile: synthetic project config content keyed
  under the wrong path, degrading emit for any file compiled via the
  synthetic single-file project fallback (basic, externals)
- registerTypeScriptDependencies: two addDependency/addBuildDependency
  call sites passed a forward-slash path straight to webpack (externals)
- createTypeScriptApiInstance: missing fileExists override for purely
  synthetic identities like component.vue.ts under appendTsSuffixTo
  (appendSuffixTo)

Also: normalizes platform-dependent path depth embedded in TS18003/
TS5055/TS6059 compiler diagnostic messages in the comparison-test
harness (same compiler behaviour on both platforms, just displayed
relative to a different reference point), adds an on-demand
windows-test-probe.yml workflow for fast, targeted Windows CI
iteration, and reduces the test retry count.

Verified against real Windows CI: all 50 comparison-test suites pass.

* docs: edit AGENTS.md / deps for sourceMaps test / time

* refactor: remove unverified Windows-fix leftovers proven unnecessary by testing

Isolated and reverted each individually against real Windows CI (full suite
where the change had broad reach, targeted tests otherwise) - all three
passed without the change, confirming they were never load-bearing:

- bumpMtimes in the comparison-test harness: added chasing a watchpack
  mtime-equality theory for dependencyErrors that turned out wrong; the
  actual fix was in getDirectResolvedImports (already in place).
- ensureSyntheticConfigForFile's files-array path normalization: added
  before the real fix (syntheticConfigContents' store-side key
  normalization, which remains); the API evidently normalizes each
  files-array entry internally regardless of separator style.
- registerTypeScriptDependencies' getConfigFileNames loop normalization:
  added speculatively alongside the confirmed addDependency fix in the
  same edit; never independently exercised by any actual failure.

Full local suite (50/50) and full Windows CI suite (50/50) still pass
with all three removed.

* chore: "target": "es2022"

* feat: chalk -> picocolors

* feat: picocolors -> styleText

* fix: test

* fix: eslint -> oxlint

* feat: styleText -> picocolors

* chore: clean unused

* chore: knip / upgrade deps

* fix: execution tests

* chore: remove experimentalWatchApi references

* chore: remove experimentalWatchApi tests

* chore: remove reference to watchapi in tests

* fix: loader options hash

* fix: loader options hash

* fix: loader options hash

* chore: update to latest nightly

* chore: upgrade lint-staged

* feat: transpileApi

* fix: normalize transpileModule/transpileDeclaration fileName for Windows

api.transpileModule/transpileDeclaration build their own virtual
filesystem from `fileName` verbatim rather than resolving it through a
Project, so an OS-native (backslash) path panics on Windows ("mixed
posix and windows paths") and also breaks diagnostic location lookup
(the echoed diagnostic.fileName no longer matches the OS-native
apiFileName used as the lookup key).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: transpileDeclaration panics on Windows given an absolute fileName

api.transpileDeclaration builds its own throwaway virtual filesystem
from `fileName` verbatim rather than resolving it through a Project,
and panics on Windows ("mixed posix and windows paths") given any
absolute path there - OS-native or forward-slash-normalized alike.
Stripping the OS-native configFilePath from compilerOptions and
falling back a rootDir were both tried first and, per the Windows
test probe workflow, neither stopped the panic.

The actual fix: pass transpileDeclaration a bare basename instead of
any absolute path at all. Unlike transpileModule (which needs
fileName's real directory for e.g. rootDir-containment diagnostics
like TS6059, and keeps its own absolute, forward-slash path),
transpileDeclaration doesn't need real directory context - its own
diagnostics (isolatedDeclarations violations) are purely syntactic,
and any real rootDir violation for the same file is already caught by
transpileModule's own call on it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: reduce comment verbosity - needs another pass

* chore: remove workarounds no longer required since microsoft/TypeScript#64024

* chore: function expressions to function declarations

* feat: knip

* refactor: use API-provided startPosition/endPosition instead of a manual location lookup

DiagnosticResponse already carries precomputed startPosition/endPosition
(zero-based line/character) on every diagnostic - program-based
(getSyntacticDiagnostics etc.) and transpileModule/transpileDeclaration
alike - present exactly when there's a real position. That makes the
manual location-resolution machinery unnecessary: getDiagnosticLocations,
the DiagnosticLocationSource interface, makeSingleFileLocationSource, and
computeLineAndCharacterFromText all existed solely to reconstruct what the
API already returns, via a fileName-keyed lookup that only worked because
callers pre-canonicalized fileName to match the API's internal spelling
(see microsoft/TypeScript#64090). buildTypeScriptError now reads
diagnostic.startPosition/endPosition directly, so no lookup is needed at
all.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: knip / simplify execution tests

* fix: tests

* fix: dont alias types

* chore: trim comments

* refactor: simplify logger

* refactor: simplify logger

* Change ColorFn type to an interface

* Fix type annotation in ColorFn interface

* chore: onlyCompileBundledFiles/context removed as options

* refactor: naming

* feat: remove fs-extra

* feat: remove rimraf

* feat: remove mkdirp

* chore: remove compilerOptions loader option

The tsgo-backed native API resolves compiler options purely from the
on-disk tsconfig.json, with no per-loader-instance override hook, so
compilerOptions has been inert since the 10.0.0 rewrite. Remove it as
a valid loader option (matching how onlyCompileBundledFiles/context
were removed) instead of leaving it silently accepted but ignored.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* test: regenerate snapshots affected by compilerOptions harness default removal

The comparison-test harness injected compilerOptions: { newLine: 'LF' }
into every test's loader options via its own default options object,
independent of each fixture's own webpack.config.js. Removing
compilerOptions as a valid loader option meant that default had to go
too (test/comparison-tests/create-and-execute-test.js), which shifts
the computed options-hash for every test that doesn't set an explicit
instance name. A number of snapshots embed that hash literally as
ts-loader-default_<hash>; regenerate them via --save-output.

Verified the full diff contains only options-hash changes, dist/index.js
stack-line normalization noise, and the couple-byte bundle size shift
from the shortened validateLoaderOptionNames error message - no actual
compiled-output changes.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs: CHANGELOG

* fix: resolve .mts/.cts relative imports for dependency tracking

relativeSpecifierExtensions (used by resolveRelativeSpecifier to match
a relative import specifier against the program's source files for
webpack dependency registration and transitive-dependant rechecking)
only tried .ts/.tsx/.d.ts/.js/.jsx, unlike the neighbouring
toDeclarationFileName which already handles .mts/.cts. A relative
import resolving to a .mts/.cts file was silently treated as
unresolved, so editing it neither registered a webpack dependency on
the importer nor triggered a diagnostics recheck of it.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* perf: only force a full snapshot rescan once per build, not per file

updateSnapshot passed { invalidateAll: true } unconditionally on every
single file compiled, forcing the native API to discard its caches and
rescan disk once per file rather than once per build - real watch-mode
wiring (a hook tied to webpack's own build/rebuild boundary) didn't
exist anywhere in the tsgo rewrite.

Add TypeScriptInstance.pendingInvalidation, consumed by the first
updateSnapshot call of a build and re-armed via a compiler.hooks.compile
tap (fires once per build/watch-rebuild in both webpack 4 and 5), so
only that first call forces the rescan; every other file compiled in
the same build reuses the snapshot it already refreshed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* perf: memoize direct-import resolution across a build's dependant recheck

findTransitiveDependants rebuilt a fresh O(n) Set of every project
file's name inside getDirectResolvedImports on every single call, and
called it once per project file for every file compiled - roughly
O(n^3) for a full build. The currently-compiling file's own imports
were also recomputed a second time (once via
registerResolvedImportDependencies, again inside the BFS).

- comparableSourceFileNames is now built once per file compiled
  (passed down to callers) instead of once per candidate file inside
  the BFS.
- Each project file's resolved-imports list is memoized in a new
  TypeScriptInstance.directImportsCache, reused across every file
  compiled in the same build via getCachedDirectResolvedImports. The
  currently-compiling file always recomputes fresh (never trusts a
  stale entry) and writes its result back, so other files' dependant
  searches - and the file's own subsequent BFS lookup - see it too,
  incidentally also fixing the double computation.
- The cache is cleared whenever pendingInvalidation forces a real
  rescan (see the prior watch-mode fix), keeping it correct across
  builds.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: key directImportsCache by FilePathKey, not raw file name

registerResolvedImportDependencies wrote cache entries keyed by
apiFileName (OS-native, from webpack), while
findTransitiveDependants/getCachedDirectResolvedImports read/wrote
entries keyed by program.getSourceFileNames() (forward-slash-
normalized). On Windows those are different strings for the same
file, so an entry written by one path could never be found by the
other - silently defeating the memoization exactly where it mattered
(the currently-compiled file's own entry).

Key by FilePathKey via each instance's ResolvedPathCache instead,
matching how instance.files/pendingDiagnostics/pendingDeclarationFiles
already canonicalize path spelling and case-sensitivity.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor: naming

* perf: memoize the .d.ts dependency scan across a build

registerTypeScriptDependencies iterated program.getSourceFileNames()
(every file in the program) on every single compiled file just to
find .d.ts files to register as dependencies - O(n) per file, O(n^2)
over a build, even though that set only changes when the program's
file set actually does.

Add getProjectDtsFileNames, memoized per project (primary or a
synthetic one-off project for an orphan file) in a new
TypeScriptInstance.projectDtsFileNamesCache, cleared alongside
directImportsCache whenever pendingInvalidation forces a real rescan.
Keyed by FilePathKey (via ResolvedPathCache) for consistency with
directImportsCache, though project config paths are already stable,
single-sourced strings in this codebase.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor: names

* fix: cap orphan-file synthetic projects with LRU eviction

ensureSyntheticConfigForFile created and permanently tracked one
synthetic tsconfig + open project per distinct orphan file (e.g. every
allowTsInNodeModules file ever compiled), with no eviction - each held
its own ref-counted project open on the API side, so a long watch
session touching many distinct orphan files leaked memory/state
proportional to all of them, unbounded.

Cap it at 20 (maxOrphanFileProjects), evicting the least-recently-used
entry - tracked via Map insertion order, bumped on reuse - once the cap
is hit. The evicted project's closeProjects is threaded through
updateSnapshot to actually release its ref-counted open on the API
side, and removed from openedProjectPaths so revisiting that file later
reopens it fresh rather than treating it as still-open.

Verified with a standalone scratch reproduction (22 distinct orphan
files under allowTsInNodeModules): exactly 2 evictions occurred against
the cap of 20, the build succeeded with no errors, and editing a
previously-evicted file was correctly picked up on the next rebuild.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: canonicalize configFilePath/syntheticConfig* via FilePath

Two real bugs, same class as the earlier directImportsCache fix:

- syntheticConfigContents's readFile/fileExists lookups used
  toComparablePath (slash-only normalization), while the sibling
  files Map right next to it already used resolvedPathCache (slash
  *and* case normalization) - a case-insensitive-filesystem spelling
  mismatch would silently miss.
- syntheticConfigFiles was keyed by raw fileName. Two importers
  spelling/casing the same orphan file differently would be treated
  as distinct files, each spawning its own redundant synthetic
  project - undermining the LRU cap added previously.

configFilePath and openedProjectPaths are converted too for
consistency, though their values were already single-sourced and
stable in practice.

Added TypeScriptInstance.resolvedPathCache so functions that only
receive TypeScriptInstance (not the outer TSInstance) - openPrimaryProject,
prepareSnapshotForFile, ensureSyntheticConfigForFile, updateSnapshot -
can canonicalize a path without threading it through as a separate
parameter.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor: rename

* refactor: names

- Use interface instead of type for the plain object shape
  TypeScriptApiModule, matching AGENTS.md's convention.
- Extract reportConfigFileParsingErrors, deduplicating the ~20-line
  broken-tsconfig error-reporting block shared by getTypeScriptEmit
  and getTranspileOnlyEmit.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor: thread resolvedFilePathCache instead of storing it twice

TypeScriptInstance.resolvedFilePathCache duplicated the exact same
function reference already stored on the owning TSInstance's own
resolvedPathCache field.

Drop the stored field; thread it as an explicit parameter through
prepareSnapshotForFile/ensureSyntheticConfigForFile instead, sourced
from instance.resolvedPathCache at the getTypeScriptEmit call site -
matching the convention already used by getProjectDtsFileNames,
registerResolvedImportDependencies, getCachedDirectResolvedImports,
and findTransitiveDependants.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* refactor: rename

* feat: split diagnostics

* feat: format

* fix: benchmark close issue

* fix: bound benchmark scenario wall-clock time to fit CI's job timeout

The tsgo sync API spawns a native child process per ts-loader instance,
making a "cold build" iteration ~10-20x more expensive than the classic
API's cheap in-process instantiation; touching a widely-imported (hub)
file is similarly ~35x more expensive per incremental rebuild due to
per-dependant recheck round trips over the sync RPC channel. The fixed
iteration counts (tuned for the classic API's cost profile) made the
cold-typeCheck and hub-touch scenarios alone take ~28 minutes combined,
blowing the 20-minute CI job timeout before a single scenario finished.

Cap each scenario's wall-clock time in run-side.mts instead of guessing
a smaller fixed iteration count, so cheap scenarios keep their full
sample size while expensive ones stop once they've collected enough
measured samples. Confirmed locally: full default run (300 files) went
from never finishing to completing in ~4 minutes.

* perf: batch transitive-dependant recheck to once per build, not once per file

Profiling the benchmark's slowness (tsgo branch showing 10-20x worse
numbers than the classic branch, contrary to tsgo's own "faster
compiler" characteristic) traced 83-91% of both cold-build and
hub-touch-rebuild time to recheckTransitiveDependants: it ran once per
file webpack compiled rather than once per build, and each call does
a full O(project size) dependant search plus two diagnostic calls per
dependant found. For a wide-fanout change (a file most of the project
depends on) that's close to O(n²) work in a single build. The raw
tsgo API itself opens a 300-file project and double-diagnoses every
file in ~25ms - it's not the bottleneck.

Batches the recheck into one pass per build instead: getTypeScriptEmit
now just records which files it compiled (changedFilesThisBuild), and
a new recheckAllTransitiveDependants runs once from the existing
postCompile hook, searching dependants of the whole changed-file set
in a single pass.

Getting this right needed two follow-up fixes surfaced by comparison
tests, both around same-build ordering:
- A changed file can itself import another changed file compiled later
  in the same build (e.g. an entry file and the dependency it just
  changed). Its own diagnostics may have been computed before that
  other file's compile updated the shared file cache the API's readFile
  override serves from. findTransitiveDependants no longer excludes
  changed files from being found as dependants of each other, so this
  gets caught and rechecked too.
- The recheck's own snapshot needs a forced full rescan
  (pendingInvalidation = true) rather than reusing the arbitrary anchor
  file's incremental view, otherwise it can still read a stale copy of
  a same-build sibling. Only costs one extra rescan per build (not per
  file), so it's affordable now.

Measured on a synthetic 300-file fixture: cold build ~9.1s -> ~1.0s,
hub-touch incremental rebuild ~4.2s -> ~300-380ms. Full comparison-test
suite (including all watch-mode tests) still passes.

* chore: newer TypeScript version

* feat: perf optimisations

* feat: perf tweaks

* fix: format

* chore: optimisations

* fix: improve transpile by applying @andrewbranch's git diff from microsoft/TypeScript#63875 (comment)

* fix: typo

* feat: have one base snapshot per total webpack build rather than one per file

* docs: cleanup unused

* feat: migrate to new snapshot API from microsoft/TypeScript#64204

* fix: resolve two Windows/virtual-file panics in the new snapshot API

Two related "no project found for opened file" Go-side panics surfaced
against a virtual (never-on-disk) identity while migrating to the new
snapshot API:

1. `toApiFacingFileName` aliases a file with an unrecognized extension
   (e.g. a Vue SFC's extracted `<script>` block, `App.vue` -> `App.vue.ts`)
   for every API-facing call, including `openFiles`. But the `fs.fileExists`/
   `readFile` host overrides looked up content keyed only by the real name,
   never by that alias, so the API's callback for `App.vue.ts` came up empty
   on both the virtual map and real disk - from the host's perspective the
   file genuinely didn't exist. Fixed by having those overrides fall back to
   the pre-alias name (`toRealFacingFileName`) on a miss.

2. Separately, on Windows only, `appendSuffixTo` (the older
   `appendTsSuffixTo` option) hit the same panic for a different reason:
   its aliased entry file is the very first file webpack compiles, so the
   very first `createSnapshot` call has to open the project and that
   not-yet-a-member file together, in one request - a combination the API
   panics on regardless of whether create or update does it. Fixed by
   catching that failure in `updateSnapshot` and retrying without
   `openFiles`, letting the existing synthetic-config fallback in
   `prepareSnapshotForFile` take over exactly as it already does for any
   later never-before-seen file.

Verified via `yarn comparison-tests` (50/50, both fixes needed for
sourceMapsShouldConsiderInputSourceMap) and via
.github/workflows/windows-test-probe.yml (50/50 on Windows, where the
second bug only reproduces).

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* chore: add standalone repro for the "no project found for opened file" panic

A minimal, ts-loader/webpack-free repro of the second panic shape
described in the PR discussion: a fresh API instance's very first
createSnapshot() call opens a project and, in the same request, opens a
file that isn't part of that project (real, inferred, or synthetic) -
which should fall back to the inferred project per
SnapshotRequestChangesParams.openFiles's own doc comment, but instead
panics on Windows. Doesn't reproduce on macOS/Linux.

Also extends windows-test-probe.yml with a repro_script input so this
(or any other standalone script) can be run on the Windows runner
on-demand, for verifying platform-specific upstream issues like this one.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: canonicalize openFiles/fileNotifications casing to match openProjects

Upgrades to typescript@next 7.1.0-dev.20260922.1 and fixes the "no project
found for opened file" failure that persisted against it on Windows (see
microsoft/TypeScript#64204 (comment)
onwards).

Per microsoft/TypeScript#64204 (comment)
and microsoft/TypeScript#64204 (comment),
the failure traces back to a Windows drive-letter casing mismatch.
ts-loader was itself contributing to that: `openProjects` always carried
`configFilePath`'s resolvedFilePathCache'd (lowercased) form, but
`openFiles` and `fileNotifications.changed`/`deleted` used `fileName`'s
natural, unmodified casing - so a single snapshot request could mix a
lowercase-drive-letter project path with a differently-cased file path.

Canonicalizes every file name sent to the API the same way project paths
already are, at the single point (`updateSnapshot`) where the wire params
are built - doesn't touch how `apiFileName` is used anywhere else
(getSourceFile, getConfiguredProject, dependency tracking, etc.), keeping
this a narrow, wire-boundary-only change.

Confirmed via .github/workflows/windows-test-probe.yml that this fix alone
is sufficient - appendSuffixTo and the full 50-suite comparison run both
pass on Windows without any additional workaround.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix: upgrade typescript nightly and fix fallout on all platforms

Bumped the floating `typescript` dependency to a newer nightly
(7.1.0-dev.20261002.1), which changed the shape of the new unstable
sync API's FileSystemCallbacks (now requires all 8 callbacks instead of
just fileExists/readFile, and undefined no longer means "defer to the
real filesystem" - that's now the explicit serverFS.useOS sentinel).
Updated typeScriptApi.ts's fs override accordingly; everything other
than fileExists/readFile now just defers to the OS via serverFS.useOS.

That nightly bump also changed the compiler's own declaration-map/
source-map emission for two existing fixtures (declarationOutputWithMaps,
tsconfigInvalid) - confirmed via a side-by-side plain `tsc` comparison
against both nightlies, not a ts-loader bug - so those fixtures are
regenerated to match the new (correct, for this compiler version) output.

Also surfaced a third, Windows-only failure in
sourceMapsShouldConsiderInputSourceMap. Root-caused via git history
(bisecting known-good/known-bad CI runs) plus a timing benchmark of
typescript/unstable/sync's out-of-process API on both nightlies/both
platforms: vue-loader's webpack5 pitching mechanism re-requests each SFC
block through the full loader chain, and which of the resulting
"pitching" vs "final" modules webpack visits first (and so which
sourcesContent index each lands at) depends on their relative completion
timing - not stable across machines or even repeated runs on one
machine. The nightly bump measured faster on both OSes but by a
different relative amount each (~30% vs ~15% cold-start, ~0% vs ~5% warm,
Mac vs Windows), a plausible trigger for flipping this pre-existing
race; the race itself predates the bump and isn't ts-loader's to fix
(tried a custom devtoolModuleFilenameTemplate first - doesn't hold,
since the instability is in which modules get created, not how they're
named). Worked around by not byte-comparing that one test's
bundle.js.map - see the comment at its call site in
create-and-execute-test.js. Also pinned *.vue to LF line endings in
.gitattributes, which isn't the cause but is a reasonable consistency
fix regardless.

* fix: format

* chore: execution tests on mac

* chore: lose unstable as mentioned in microsoft/TypeScript#64709

* fix: can do prerelease

* docs: README

* fix: logger not respecting option

* fix: typescript version

* chore: version upgrade

* fix: lockfile churn

* chore: upgrade to 7.1.0-beta

* feat: newImportedFileWatch test

* refactor: use createPrograms for orphan files instead of synthetic tsconfigs

* fix: don't export SyntheticProgram (knip)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* refactor: layer webpack-supplied content into the snapshot instead of fs callbacks

Each compiled file's content is now added as a persistent fileSystem layer
on the instance snapshot (sent in the same request as any openFiles for it),
replacing the readFile/fileExists callbacks and runWithTemporaryFileUpdate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: add an example

* docs: README and CHANGELOG fixes for 7.1.0-beta

- install typescript@beta rather than next
- list projectReferences among the accepted-but-inert options
- correct errorFormatter's colors type

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: detect filesystem case sensitivity and pass it to the API

useCaseSensitiveFileNames now defaults to probing the volume the tsconfig.json
is on (as tsc does, and as v9 did via ts.sys) instead of assuming
case-sensitive on every non-Windows platform, and the resolved value is passed
to the TypeScript API so both agree on which paths are the same file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: point README at examples/simple and drop links to removed examples

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: describe project references support accurately for v10

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: fail watch tests promptly and support deleting files in patches

A failed assertion thrown from webpack's watch callback left the watcher
open, so mocha never exited; the harness now closes it and fails the test.
A patch file named <file>.__deleted__ now deletes <file> when applied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: recheck dependants of deleted and re-created files in watch mode

- compare paths canonically (via resolvedFilePathCache) when finding a
  changed file's dependants: the API echoes back the casing it was given,
  so on a case-insensitive filesystem exact-string comparison found none
- treat a modified file the program didn't previously contain as created:
  clear directImportsCache (other files' imports may now resolve) and tell
  the API it was created
- merge, rather than overwrite, unconsumed watcher changes, so a rebuild
  that compiles nothing (e.g. a pure deletion) doesn't lose them

Adds the deletedFileWatch comparison test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: send real-cased paths to the TypeScript API

ts-loader passed its canonical (lowercased, when case-insensitive) paths to
the API, which echoes back whatever casing it is given - so on Windows, and on
macOS since case sensitivity is detected, TypeScript's messages showed
lowercased paths. The canonical form is now only used for ts-loader's own
cache keys; openProjects, openFiles and file notifications get real-cased
paths.

The comparison test harness no longer forces useCaseSensitiveFileNames: true,
so the default is tested on every OS; snapshots change only in the
options-derived instance hash.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: evict synthetic programs in a request of their own

Sending removePrograms in the same snapshot update as createPrograms crashes
tsgo 7.1.0-beta (nil dereference in ProjectCollectionBuilder.HandleAPIRequest),
so any project with more than 20 orphan files killed the compiler process
once the synthetic-program cap started evicting. Adds manyOrphanFiles (25
orphan files) as a regression test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* perf: share one synthetic program across all orphan files

Files outside the configured project each got their own synthetic program
(capped at 20, least-recently-used evicted), each a near-complete copy of
the project - so a tsconfig whose files list only a .d.ts (every module an
orphan) rebuilt programs constantly: 8.1s vs 0.6s for the same 300-file
fixture with an include glob. They now share one program, as classic
ts-loader's single language service did, whose extra roots are only the
orphan files it doesn't already contain via an import.

Being a superset of the primary project, it also gives the transitive-
dependant recheck the full import graph, so dependants of a changed orphan
file are rechecked again (a regression from classic).

Adds an all-orphan-files variant of the benchmark fixture with cold and
hub-touch typeCheck scenarios: -92% and -95% vs the previous commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: add orphanDependantWatch comparison test

Every module is an orphan (the tsconfig lists only a .d.ts); changing an
imported file's type must still be reported in the unchanged importer,
which only the transitive-dependant recheck catches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Update CHANGELOG with details on unsupported features

Clarified the status of unsupported features in the CHANGELOG.

* Update README to remove v10 upgrade notes

Removed sections on upgrading to v10 and Yarn Plug’n’Play from the README.

* docs: improve README

* chore: prepare 10.0.0-beta.0 release

- set version to 10.0.0-beta.0
- restrict typescript peer dependency to >=7.1.0-beta
- add a files allowlist so only built output is published
- document installing the beta via the next dist-tag

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: report diagnostics for unbundled project files and drop stale ones

- type-check project files webpack doesn't bundle (all on the first build,
  then the ones webpack's watcher reports changed), and watch them so edits
  trigger a rebuild - matching v9 without onlyCompileBundledFiles
- drop stored diagnostics and declaration files for files that are no
  longer in the program or a webpack module, e.g. deleted files
- comparison-test harness records diagnostics-only rebuilds (same hash)
- update fixture .d.ts files to valid TS 7 syntax

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: resolve import dependencies with the native module resolver

Dependency tracking and the transitive-dependant recheck only followed
relative specifiers, resolved by hand, so a change reached through a
tsconfig paths alias (or baseUrl, package exports, ...) left stale
diagnostics. Resolve every import via the program's
getResolvedModuleFromModuleSpecifier instead, batched into one round trip
per pass, skipping unresolved and external-library imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: John Reilly <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
@jakebailey Jake Bailey (jakebailey) added the Domain: Performance Performance related label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Domain: Performance Performance related

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants