Add native-preview API: getSourceFiles, TypeParameter getters, StructuredType, TupleTypeReference, inferredProjectName#4564
Open
aamoghS wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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", () => { |
138b5a6 to
d290c2e
Compare
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
f80e12f to
bfb803c
Compare
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
Programis missing.getSourceFiles()getter #4502: AddProgram.getSourceFiles()to the async and sync native-preview APIs, composinggetSourceFileNames()andgetSourceFile()..getConstraint()and.getDefault()getter toTypeParameter#4553: AddgetConstraint()/getDefault()onTypeParameter, backed by a newgetDefaultOfTypeParameterGo endpoint (constraint already had a checker endpoint).TupleTypeReferenceinterface to the API #4499: AddTupleTypeReferenceinterface for narrowing afterchecker.isTupleType().StructuredTypetype to the API #4539: AddStructuredTypeas the common supertype ofObjectTypeandUnionOrIntersectionType, withisStructuredType().inferredProjectNameconstant from the API #4519: ExportinferredProjectNameconstant (/dev/null/inferred).Closes #4502. Fixes #4553, #4499, #4539, #4519.
Test plan
tsc -bandtsc -b testpass for native-previewgo build ./internal/api/...passesnpm testin_packages/native-preview(requires Node 22+ for the test runner)getSourceFiles,TypeParameter.getConstraint/getDefault,isStructuredType,TupleTypeReference.getTarget,inferredProjectName