The following code snippet implements an application that is almost identical to the application that we implemented in the preceding section. The most notable difference is that, instead of using the core TypeScript compiler APIs, we are going to use the ts-simple-ast helpers:
import chalk from "chalk"; import Ast, { DiagnosticMessageChain } from "ts-simple-ast";
The following function is used in many of the examples in this chapter, and it is used to get an instance of the TypeScript AST, given certain files and the desired compiler settings:
function getAst(tsConfigPath: string, sourceFilesPath: string) { const ast = new Ast({ tsConfigFilePath: tsConfigPath, addFilesFromTsConfig: false }); ast.addExistingSourceFiles(sourceFilesPath); ...