Repository navigation
[api] AST utility APIs - #65586
Open
Andrew Branch (andrewbranch) wants to merge 13 commits into
Open
[api] AST utility APIs#65586Andrew Branch (andrewbranch) wants to merge 13 commits into
Andrew Branch (andrewbranch) wants to merge 13 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved bugs affect keyword recognition, modifier handling, type narrowing, and JSDoc variadic detection, while flag lookup can throw on detached binding elements.
6 open issues
Recognize JSDoc type aliases as modifier-bearing declarations · New Include JS imports in the modifier type guard · New Return stored modifiers for recovery nodes · New Addimmediateto the shared keyword table · New Skip qualified-name tags when finding the last JSDoc parameter · New Handle detached binding elements in root declaration lookup · New
What changed in this PR
Expands the TypeScript JavaScript API with AST inspection utilities and access to native formatting defaults.
Changes:
- Adds modifier/decorator guards, ancestor and flag helpers, rest-parameter detection, keyword lookup, and
Node.getModifiers(). - Exposes default formatting settings through the native protocol and async/sync clients.
- Improves private-symbol display names and adds coverage for the new APIs.
| File | Description |
|---|---|
tsc/internal/ls/lsutil/formatcodeoptions.go |
Serializes formatting settings with string-valued indentation styles. |
tsc/internal/api/session.go |
Handles formatting-default requests and supplies symbol display names. |
tsc/internal/api/proto.go |
Adds the formatting method and symbol display-name field. |
tools/scripts/tsc/generate-ts-ast.ts |
Generates factory-node getModifiers() methods. |
tools/scripts/tsc/generate-encoder.ts |
Generates remote-node getModifiers() methods. |
tools/gen-proto/main.go |
Maps native formatting settings to the client type. |
tools/gen-proto/main_test.go |
Checks generated formatting-method declarations. |
packages/typescript/test/sync/ast.test.ts |
Covers the new AST utilities and node method. |
packages/typescript/test/sync/api.test.ts |
Tests formatting defaults and private-symbol names. |
packages/typescript/test/sync/api-generators.test.ts |
Checks formatting-method generator parity. |
packages/typescript/test/scanner.test.ts |
Tests identifier-to-keyword lookup. |
packages/typescript/test/async/api.test.ts |
Covers async formatting defaults and private-symbol names. |
packages/typescript/src/ast/utils.ts |
Adds rest-parameter and combined-node-flag helpers. |
packages/typescript/src/ast/scanner.ts |
Exports identifier-to-keyword lookup. |
packages/typescript/src/ast/modifiers.ts |
Adds shared modifier extraction without decorators. |
packages/typescript/src/ast/is.ts |
Adds declaration guards and exports ancestor traversal. |
packages/typescript/src/ast/factory.generated.ts |
Implements getModifiers() on factory nodes. |
packages/typescript/src/ast/ast.ts |
Declares modifier/decorator unions and the node method. |
packages/typescript/src/api/sync/api.ts |
Exposes formatting defaults and consumes symbol display names. |
packages/typescript/src/api/proto.generated.ts |
Updates generated protocol types and batch-method lists. |
packages/typescript/src/api/node/node.generated.ts |
Implements getModifiers() on remote nodes. |
packages/typescript/src/api/async/api.ts |
Adds async formatting defaults and symbol display-name handling. |
Review effort: Balanced
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>
Andrew Branch (andrewbranch)
force-pushed
the
ast-utility-apis
branch
from
November 19, 2026 20:22
f8f788e to
b423761
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the API expansion.
No open issues 🎉
6 resolved since last review
Handle detached binding elements in root declaration lookup Skip qualified-name tags when finding the last JSDoc parameter Addimmediateto the shared keyword table Return stored modifiers for recovery nodes Include JS imports in the modifier type guard Recognize JSDoc type aliases as modifier-bearing declarations
Review effort: Balanced
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> # Conflicts: # packages/typescript/src/api/node/node.generated.ts # packages/typescript/src/ast/ast.ts
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Nov 20, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> # Conflicts: # packages/typescript/src/api/async/api.ts # packages/typescript/src/api/sync/api.ts
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.


canHaveDecoratorscanHaveModifiersfindAncestorgetCombinedNodeFlagsAPI.getDefaultFormatCodeSettingsNode.getModifiershasRestParameteridentifierToKeywordKind