Creating a TypeScript Program with the API
Initialize a compiler program and access the type checker.
What Is the Compiler API?
TypeScript exposes its compiler internals through the typescript npm package. You can create programs, inspect the type checker, and analyze source files programmatically.
import ts from "typescript";
// Use ts.createProgram to startInstalling the typescript Package
Install TypeScript as a regular dependency (not just devDependency) when using the compiler API in your tools.
npm install typescript
# Also install types if needed
npm install --save-dev @types/nodeAll lessons in this course
- Creating a TypeScript Program with the API
- Traversing the AST with Visitors
- Custom Transformers and Code Generation
- Building a Simple Linting Tool