fix(plugin): support TypeScript project references in ReadonlyVisitor#3804
Merged
kamilmysliwiec merged 1 commit intonestjs:masterfrom Apr 9, 2026
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #3641
Bug: The Swagger plugin fails with TS6305 errors when used in a TypeScript project that uses
references(composite project references) intsconfig.json.Root Cause:
ts.createProgram({ ..., projectReferences })requires pre-built output files (.d.ts) from each referenced composite project, triggering TS6305 when those outputs do not exist yet.Fix: A new static method
ReadonlyVisitor.createTsProgram(tsconfigPath)recursively collects source files from all transitively referenced projects (with cycle detection) and creates the program with mergedrootNamesbut without passingprojectReferences, bypassing TS6305 while still resolving all types across the project graph.Changes
lib/plugin/visitors/readonly.visitor.ts: AddedcollectProjectReferenceSourceFileshelper andReadonlyVisitor.createTsProgram()static method that handles composite project references without requiring pre-built outputs.test/plugin/readonly-visitor-project-refs.spec.ts: 5 new tests covering thecreateTsProgrammethod with project reference fixtures.test/plugin/fixtures/project-references/: New fixture with anappproject referencing alibs/sharedcomposite project, used by the new tests.Testing
test/plugin/readonly-visitor-project-refs.spec.tsthat verifycreateTsProgramworks correctly with a project using composite project references, handles missing tsconfig gracefully, detects cycles, and collects source files from transitive references.