Skip to content

API: add getChildren and token getters to Node - #63893

Open
Matheus Mol (oMatheusmol) wants to merge 3 commits into
microsoft:mainfrom
oMatheusmol:api/node-child-token-getters
Open

API: add getChildren and token getters to Node#63893
Matheus Mol (oMatheusmol) wants to merge 3 commits into
microsoft:mainfrom
oMatheusmol:api/node-child-token-getters

Conversation

@oMatheusmol

Copy link
Copy Markdown
Contributor

Fixes #63892

Adds the remaining child/token getters to the native API's Node: getChildren(), getChildCount(), getChildAt(), getFirstToken() and getLastToken().

Context

This is a re-submission of a contribution originally made to the typescript-go repo. I previously contributed the position/text getters in microsoft/typescript-go#4308, and this follow-up (completing microsoft/typescript-go#4216) was submitted as microsoft/typescript-go#4440. That PR was closed when development moved back to this repository, and the maintainers asked contributors to re-open their PRs here — so here it is.

Compared to the original PR, the only changes are path remappings to this repo's layout (_packages/native-preview/packages/typescript/, _scripts/tools/scripts/tsc/) and a rebase onto current main. It also incorporates the review feedback from the original PR (reusing shouldSkipChild instead of duplicating the JSDoc predicate).

Validation

  • npm run generate reproduces the generated files (node.generated.ts, factory.generated.ts) with no extra diff
  • npm run build in packages/typescript passes
  • npm test in packages/typescript: 612 tests pass, 0 fail (includes the new getChildren/token getter tests in test/sync/ast.test.ts)

Adds the remaining child/token getters to the API: getChildren, getChildCount, getChildAt, getFirstToken, getLastToken.
Copilot AI balanced review requested due to automatic review settings August 20, 2026 05:25
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 20, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 20, 2026

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 child and token navigation getters to the native TypeScript Node API.

Changes:

  • Implements child/token materialization and caching.
  • Adds getters to local and remote nodes via generators.
  • Adds comprehensive AST navigation tests.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/scripts/tsc/generate-ts-ast.ts Generates local node getters.
tools/scripts/tsc/generate-encoder.ts Generates remote node getters.
packages/typescript/test/sync/ast.test.ts Tests child/token navigation.
packages/typescript/src/ast/factory.generated.ts Adds generated local getters.
packages/typescript/src/ast/astnav.ts Implements navigation and caching.
packages/typescript/src/ast/ast.ts Extends the public node interfaces.
packages/typescript/src/api/node/node.generated.ts Adds generated remote getters.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/typescript/src/ast/astnav.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

API: Node is missing getChildren(), getFirstToken(), getLastToken() and related getters

2 participants