Skip to content

Add missing Program and Project Methods - #64988

Open
Isabel Duan (iisaduan) wants to merge 4 commits into
microsoft:mainfrom
iisaduan:programApi
Open

Isabel Duan (iisaduan) wants to merge 4 commits into
microsoft:mainfrom
iisaduan:programApi

Conversation

@iisaduan

@iisaduan Isabel Duan (iisaduan) commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Missing Program API methods: https://github.com/microsoft/TypeScript/pull/64749/changes#diff-4776036ff539c2fa009621dc13a9f2c8fd15d50e9302e8a361614ab640659a2eR117

  • getIdentifierCount() - 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 existing Checker object.
  •  getTypeCount() - Number of types allocated by the API checker.

Project API Methods:

  •  containsFile
  •  getFileNames
  •  getRootFiles
  •  hasRoots,
  • isRoot 
  •  hasConfigFile
  •  getSourceFile

@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 28, 2026
@iisaduan Isabel Duan (iisaduan) changed the title program init Add missing Program and Project Methods Oct 28, 2026
@iisaduan
Isabel Duan (iisaduan) marked this pull request as ready for review October 28, 2026 07:27
Copilot AI balanced review requested due to automatic review settings October 28, 2026 07:27

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.

🟡 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 thread tsc/internal/api/session.go Outdated
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants