Ts-morph: [Question] How to traverse a TS node?

Created on 4 Aug 2019  路  1Comment  路  Source: dsherret/ts-morph

Hi,

I want to know how to traverse a AST tree?
I want to visit any node and find each comment.
Something like walk-parse5


walk(documentOrNode, node => {
    if (node['type'] && node['type'] === 'comment') {
        var data = <string>node['data'];
    }
});
question

Most helpful comment

Hey @HamedFathi,

See this page: https://dsherret.github.io/ts-morph/navigation/

I think you're probably look for either the forEachChild or forEachDescendant method.

>All comments

Hey @HamedFathi,

See this page: https://dsherret.github.io/ts-morph/navigation/

I think you're probably look for either the forEachChild or forEachDescendant method.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HamedFathi picture HamedFathi  路  3Comments

pierregallard picture pierregallard  路  4Comments

mi5ha picture mi5ha  路  3Comments

dsherret picture dsherret  路  3Comments

GrandSchtroumpf picture GrandSchtroumpf  路  4Comments