Created
August 20, 2020 12:38
-
-
Save roytouw7/230d27f8b5e56c98e1418472f23a26c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Recursively visit every node in sourcefile. | |
const visitSourceFile = (sourceFile: ts.SourceFile, context: ts.TransformationContext): ts.SourceFile => { | |
const imports = new Set<RxJSPart>(); | |
const visitNodes = (node: ts.Node): ts.Node => { | |
const [dispatchedNode, classification] = dispatch(node); | |
imports.add(classification); | |
return ts.visitEachChild(dispatchedNode, visitNodes, context); | |
}; | |
const root = visitNodes(sourceFile) as ts.SourceFile; | |
return addImports(root, imports) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment