Skip to content

[api] AST utility APIs - #65586

Open
Andrew Branch (andrewbranch) wants to merge 13 commits into
microsoft:mainfrom
andrewbranch:ast-utility-apis
Open

Andrew Branch (andrewbranch) wants to merge 13 commits into
microsoft:mainfrom
andrewbranch:ast-utility-apis

Conversation

@andrewbranch

Copy link
Copy Markdown
Member
  • canHaveDecorators
  • canHaveModifiers
  • findAncestor
  • getCombinedNodeFlags
  • API.getDefaultFormatCodeSettings
  • Node.getModifiers
  • hasRestParameter
  • identifierToKeywordKind

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

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
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

Comment thread packages/typescript/src/ast/is.ts Resolved
Comment thread packages/typescript/src/ast/is.ts Resolved
Comment thread packages/typescript/src/ast/scanner.ts Resolved
Comment thread packages/typescript/src/ast/utils.ts Resolved
Comment thread packages/typescript/src/ast/utils.ts Resolved
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>

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.

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

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 new API test could miss regressions in the encoded indent style and boolean defaults because it does not assert those values.

1 open issue

Review effort: Balanced

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.

🟢 Approval recommended

No outstanding review findings remain for the TypeScript API expansion.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

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.

3 participants