Repository navigation
Add missing Program and Project Methods - #64988
Open
Isabel Duan (iisaduan) wants to merge 4 commits into
Open
Isabel Duan (iisaduan) wants to merge 4 commits into
Isabel Duan (iisaduan) wants to merge 4 commits into
Conversation
Isabel Duan (iisaduan)
marked this pull request as ready for review
October 28, 2026 07:27
Contributor
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
Comment on lines
+2582
to
+2596
| file := sd.snapshot.GetFile(fileName) | ||
| if file == nil { | ||
| return false, nil | ||
| } | ||
| path := sd.snapshot.CaseSensitivity().PathKey(fileName.AsPath()) | ||
| if params.RequireOpen && !sd.snapshot.ProjectCollection.IsFileOpen(path) { | ||
| return false, nil | ||
| } | ||
| for _, root := range proj.CommandLine.FileNames() { | ||
| if sd.snapshot.CaseSensitivity().PathKey(root.AsPath()) == path { | ||
| return true, nil | ||
| } | ||
| } | ||
| program := proj.GetProgram() | ||
| return program != nil && program.GetSourceFileByPath(path) != nil, nil |
This branch has not been deployed
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.

Missing
ProgramAPI methods: https://github.com/microsoft/TypeScript/pull/64749/changes#diff-4776036ff539c2fa009621dc13a9f2c8fd15d50e9302e8a361614ab640659a2eR117getIdentifierCount()- Total parsed identifiers across the program’s source files.getInstantiationCount()- Number of type-instantiation operations performed by the API checker.getNodeCount()- Total syntax-tree nodes across the program’s source files.getOptionsDiagnostics()- Sorted, deduplicated compiler-option and configuration-related program diagnostics. Excludes source-file and config-parsing diagnostics.getProjectReferences()- Direct project references declared for the program, or undefined when absent.getRelationCacheSizes()- Current entry counts in the checker’s assignable , identity , subtype , and strictSubtype caches.getResolvedProjectReferences()- Resolved reference graph, including parsed configurations, config source files, and nested references. Preserves shared/circular references and missing entries.getRootFileNames()- Root file names supplied when creating the program or obtained from its configuration—not imported dependencies.getSourceFiles()- All loaded source files, including dependencies and libraries, in program order. Reuses cached source-file objects.getSymbolCount()- Binder-created symbols across source files plus symbols allocated by the API checker.getTypeChecker()- Initializes the server-side API checker if necessary and returns the project’s existingCheckerobject.getTypeCount()- Number of types allocated by the API checker.ProjectAPI Methods:containsFilegetFileNamesgetRootFileshasRoots,isRoothasConfigFilegetSourceFile