Minimal reproduction showing that program.isSourceFileDefaultLibrary() returns false
after full program structure reuse via oldProgram in TypeScript 6.
When tryReuseStructureFromOldProgram returns StructureIsReused.Completely, the new
program never populates its libFiles Set and doesn't copy it from the old program.
This means isSourceFileDefaultLibrary — which checks membership in that set — always
returns false for the reused program.
Caused by microsoft/TypeScript#62435
pnpm install
pnpm testThe test suite runs checkIsSourceFileDefaultLibraryAfterReuse against three TypeScript
versions:
typescript-5: TypeScript 5.9.3typescript-6: TypeScript 6.0.0-betatypescript-6-patched: TypeScript 6.0.1-rc with a quick-and-dirty patch to validate the bug.
I'm using rc for the patch version only to be able to have both patched and unpatched versions in the same project, it doesn't have anything to do with the bug itself.
I used AI to generate the reproduction to save some time. The bug and the solution were discovered manually by me when working on ts-eslint upgrade to TypeScript 6 (typescript-eslint/typescript-eslint#12124).