What is a `Node` in typescript (using TypeChecker) -


using answer this question reference. node , how instance of node program.

the answer question above used example type information @ location (which do)

let typechecker = program.gettypechecker(); let type = typechecker.gettypeatlocation(node); 

now i'm missing 1 last piece of puzzle. node of object pass gettypeatlocation , how instance of node.

you can top-level node source file you're interested in processing so:

const root = program.getsourcefile(filename); 

or if want process whole lot:

const roots = program.getsourcefiles(); 

then can recursively traverse tree:

processnode(root);  function processnode(node: ts.node) {    // process node    // ....     // go further down tree    ts.foreachchild(node, child => processnode(child)); } 

with should able use likes of typechecker.getsymbolatlocation() , typechecker.gettypeatlocation() devise solution other question.

if don't need modify source files plan process may easier write custom tslint rule.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -