Repository navigation
Add missing Program and Project Methods - #64988
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The filesystem check incorrectly excludes in-program supplemental files without physical files, causing containsFile to return false even when getSourceFile succeeds.
1 open issue
What changed in this PR
Adds missing Program and Project methods to the JavaScript API, backed by native compiler and project services.
Changes:
- Exposes program statistics, checker access, file lists, option diagnostics, and resolved project references.
- Adds project membership, root-file, and configuration-file queries.
- Updates protocol definitions and generated synchronous APIs, with behavioral and generator-parity tests.
| File | Description |
|---|---|
tsc/internal/project/projectcollection.go |
Checks editor- and API-open files. |
tsc/internal/compiler/program.go |
Collects filtered option diagnostics. |
tsc/internal/checker/types.go |
Defines relation-cache statistics. |
tsc/internal/checker/exports.go |
Exposes relation-cache entry counts. |
tsc/internal/api/session.go |
Implements new API request handlers. |
tsc/internal/api/session_program_test.go |
Tests membership, statistics, and checker reuse. |
tsc/internal/api/proto.go |
Defines new requests and response types. |
packages/typescript/test/sync/api.test.ts |
Adds generated synchronous API tests. |
packages/typescript/test/sync/api-generators.test.ts |
Checks generator parity for new methods. |
packages/typescript/test/async/api.test.ts |
Tests new methods and edge cases. |
packages/typescript/src/api/sync/api.ts |
Adds generated synchronous and generator methods. |
packages/typescript/src/api/proto.generated.ts |
Updates generated protocol declarations. |
packages/typescript/src/api/async/api.ts |
Implements asynchronous Program and Project methods. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent cold-cache calls can return inconsistent project-reference object identities, while sequential per-file requests prevent automatic batching and add a round trip for each file.
2 open issues
1 resolved since last review
Review effort: Balanced
Andrew Branch (andrewbranch)
left a comment
There was a problem hiding this comment.
In addition to the inline comments, let's remove
program.getSourceFiles()—not a good idea for anyone to do this pre-filtering; we'll think about an explicitly filtered and/or streaming batch API in the futureprogram.getTypeChecker()—that's not the ownership model anymore, and there's no reason to make an API request for it- all of the
Projectmethods; they can all be done more directly offProgramandParsedCommandLineso I don't want to expand that API surface unnecessarily.
|
removed |

Missing
ProgramAPI methods: https://github.com/microsoft/TypeScript/pull/64749/changes#diff-4776036ff539c2fa009621dc13a9f2c8fd15d50e9302e8a361614ab640659a2eR117getProjectReferences()- Direct project references declared for the program, or undefined when absent.getRootFileNames()- Root file names supplied when creating the program or obtained from its configuration—not imported dependencies.getStatistics()- Returns counts for symbols, identifiers, instantiations, nodes, and types, as well as relaction cache sizes.ProgramAPI methods deffered:getSourceFiles()- Add missing Program and Project Methods #64988 (review)ProgramAPI methods removed:getTypeChecker()- No longer in the ownership modelgetOptionsDiagnostics()- reduce duplicate methodsgetTypeCount,getSymbolCount,getRelationCacheSizes,getIdentifierCount,getInstantiationCount,getNodeCount- removed-- useGetStatistics(), which returns all of theseProjectAPI Methods removed in order to reduce duplicate methods across objectscontainsFilegetFileNamesgetRootFileshasRoots,isRoothasConfigFilegetSourceFile