dsherret / dsherret/ts-morph

Add ability to traverse tree in post order

Open
#513 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

Instead of #512, there could instead be an option to traverse in post order.

For example:

```ts
enum TreeOrder {
Pre = "pre",
Post = "post"
}

node.forEachDescendant(TreeOrder.Post, (node, traversal) => {
console.log(node.getText());
});

node.getDescendantsOfKind(SyntaxKind.ClassDeclaration, TreeOrder.Post);
```

See [this comment](https://github.com/dsherret/ts-simple-ast/issues/512#issuecomment-447601251).

Also, when the tree order is pre and a "node was forgotten" error occurs, it should suggest to the user to use post order.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.