Created
August 20, 2020 12:37
-
-
Save roytouw7/01bb087ea461c809c3fae0f188cbfdad 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