Repository navigation
[api] AST predicate APIs - #65590
Open
Andrew Branch (andrewbranch) wants to merge 34 commits into
Open
[api] AST predicate APIs#65590Andrew Branch (andrewbranch) wants to merge 34 commits into
Andrew Branch (andrewbranch) wants to merge 34 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The AST predicates omit JSDoc-specific declaration kinds and mishandle nameless array-binding elements, causing valid declarations to be filtered out and hole-only patterns to be misclassified.
2 open issues
What changed in this PR
Expands the TypeScript AST API with predicates for node classification, optional chains, binding patterns, and type-only declarations.
Changes:
- Adds AST predicates and a relative module-name helper.
- Introduces supporting types for narrowed predicate results.
- Adds runtime and type-narrowing tests, including parsed-source coverage.
| File | Description |
|---|---|
packages/typescript/test/astPredicates.test.ts |
Tests predicate behavior and type narrowing. |
packages/typescript/src/ast/utils.ts |
Adds relative module-name detection. |
packages/typescript/src/ast/is.ts |
Implements the new AST predicates. |
packages/typescript/src/ast/ast.ts |
Defines supporting branded types and type-only declaration unions. |
Review effort: Balanced
Andrew Branch (andrewbranch)
force-pushed
the
ast-predicate-apis
branch
from
November 19, 2026 20:19
ace4223 to
0c9691c
Compare
Andrew Branch (andrewbranch)
force-pushed
the
ast-predicate-apis
branch
from
November 19, 2026 21:25
a84621b to
6d51b1b
Compare
Andrew Branch (andrewbranch)
marked this pull request as ready for review
November 19, 2026 21:30
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Nov 20, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
Andrew Branch (andrewbranch)
force-pushed
the
ast-predicate-apis
branch
from
November 20, 2026 17:08
6c8ee55 to
1600639
Compare
Andrew Branch (andrewbranch)
enabled auto-merge
November 20, 2026 17:11
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.

These aren't auto-generated because they check multiple kinds for which there's no union type alias, or check additional properties or subtree structure.
isAutoAccessorPropertyDeclarationisCallChainisClassElementisClassOrTypeElementisConstTypeReferenceisDeclarationStatementisElementAccessChainisEmptyBindingElementisEmptyBindingPatternisExternalModuleNameRelativeisFunctionLikeisFunctionOrConstructorTypeNodeisImportOrExportSpecifierisIterationStatementisJsxCallLikeisNonNullChainisNullishCoalesceisObjectLiteralElementisOptionalChainisParameterPropertyDeclarationisPartOfTypeNodeisPartOfTypeOnlyImportOrExportDeclarationisPropertyAccessChainisPropertyAccessOrQualifiedNameisRestParameterisStringLiteralOrJsxExpressionisStringTextContainingNodeisTypeElementisTypeOnlyExportDeclarationisTypeOnlyImportDeclarationisTypeOnlyImportOrExportDeclaration