Skip to content

Add native-preview API: getSourceFiles, TypeParameter getters, StructuredType, TupleTypeReference, inferredProjectName#4564

Open
aamoghS wants to merge 3 commits into
microsoft:mainfrom
aamoghS:fix/api-getters-batch
Open

Add native-preview API: getSourceFiles, TypeParameter getters, StructuredType, TupleTypeReference, inferredProjectName#4564
aamoghS wants to merge 3 commits into
microsoft:mainfrom
aamoghS:fix/api-getters-batch

Conversation

@aamoghS

@aamoghS aamoghS commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Closes #4502. Fixes #4553, #4499, #4539, #4519.

Test plan

  • tsc -b and tsc -b test pass for native-preview
  • go build ./internal/api/... passes
  • npm test in _packages/native-preview (requires Node 22+ for the test runner)
  • New API tests: getSourceFiles, TypeParameter.getConstraint/getDefault, isStructuredType, TupleTypeReference.getTarget, inferredProjectName

Copilot AI review requested due to automatic review settings July 8, 2026 17:57

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.

Pull request overview

Adds a Program.getSourceFiles() convenience API to the native-preview async and sync Program wrappers, allowing consumers to retrieve SourceFile objects directly without manually iterating getSourceFileNames() and calling getSourceFile() per entry.

Changes:

  • Added Program.getSourceFiles() to the async API implementation and mirrored it in the sync API.
  • Added async and sync API tests covering getSourceFiles() basic behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
_packages/native-preview/src/api/async/api.ts Adds Program.getSourceFiles() convenience method to the async API.
_packages/native-preview/src/api/sync/api.ts Adds the sync counterpart of Program.getSourceFiles().
_packages/native-preview/test/async/api.test.ts Adds an async test validating getSourceFiles() returns files corresponding to getSourceFileNames().
_packages/native-preview/test/sync/api.test.ts Adds a sync test validating getSourceFiles() returns files corresponding to getSourceFileNames().

Comment on lines +651 to +655
/**
* Returns all source files in the program. Convenience wrapper over
* {@link getSourceFileNames} and {@link getSourceFile}; any file that cannot
* be loaded is omitted.
*/
Comment on lines +659 to +663
/**
* Returns all source files in the program. Convenience wrapper over
* {@link getSourceFileNames} and {@link getSourceFile}; any file that cannot
* be loaded is omitted.
*/
}
});

test("getSourceFiles returns a source file for every program file name", async () => {
}
});

test("getSourceFiles returns a source file for every program file name", () => {
@aamoghS aamoghS force-pushed the fix/api-getters-batch branch from 138b5a6 to d290c2e Compare July 9, 2026 01:04
@aamoghS aamoghS changed the title Add Program.getSourceFiles() to native-preview API Add native-preview API: getSourceFiles, TypeParameter getters, StructuredType, TupleTypeReference, inferredProjectName Jul 9, 2026
aamoghS added 3 commits July 8, 2026 21:33
Adds a getSourceFiles() convenience getter to the async and sync Program classes, composing getSourceFileNames() and getSourceFile(). Closes microsoft#4502.
…edProjectName

- microsoft#4553: getConstraint()/getDefault() on TypeParameter via getDefaultOfTypeParameter endpoint

- microsoft#4499: TupleTypeReference interface for isTupleType narrowing

- microsoft#4539: StructuredType supertype with isStructuredType()

- microsoft#4519: export inferredProjectName constant

Fixes microsoft#4553, microsoft#4499, microsoft#4539, microsoft#4519
@aamoghS aamoghS force-pushed the fix/api-getters-batch branch 2 times, most recently from f80e12f to bfb803c Compare July 9, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add .getConstraint() and .getDefault() getter to TypeParameter Program is missing .getSourceFiles() getter

2 participants