Created
September 20, 2017 02:31
-
-
Save jthoms1/5b36b64151ed0036d1f9413b72146c19 to your computer and use it in GitHub Desktop.
Typescript transform test tool
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
function transformSourceFile(sourceText: string, transformers: ts.TransformerFactory<ts.SourceFile>[]) { | |
const transformed = ts.transform(ts.createSourceFile('source.ts', sourceText, ts.ScriptTarget.ES2015), transformers); | |
const printer = ts.createPrinter({ newLine: ts.NewLineKind.CarriageReturnLineFeed }, { | |
onEmitNode: transformed.emitNodeWithNotification, | |
substituteNode: transformed.substituteNode | |
}); | |
const result = printer.printBundle(ts.createBundle(transformed.transformed)); | |
transformed.dispose(); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment