TypeScript Compiler API
Parent: TypeScript Expert · Published reference · snapshot 2026-09-08 · skill lang-js-ts/references/typescript-compiler-api.md
↓ Facts as markdownall context files
A lang-js-ts reference for driving the typescript npm package as a library — parsing source to
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
TypeScript Compiler API & Programmatic Tooling (Strada)
- A lang-js-ts reference for driving the typescript npm package as a library - parsing source to an AST, type-checking through the TypeChecker, rewriting code with custom transformers built on the modern ts.factory node API, hosting the Language Service, and the ts-morph wrapper that makes all of it ergonomic. This is the engine behind linters, codemods, code generators, doc tools, and editor plugins. For the type system and tsconfig defer to typescript-expert.md / typescript-compiler-config; for running .ts (type stripping, tsx, ts-node) defer to nodejs-typescript-and-runtime-features.md. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#typescript-compiler-api-programmatic-tooling-strada]
Overview
- The compiler ships one public module (import * as ts from "typescript") exposing the same pipeline tsc uses: a scanner/parser turns text into an immutable AST (ts.SourceFile of ts.Nodes); a binder + TypeChecker resolve symbols and types; transformers rewrite the tree; a printer/emitter writes .js/.d.ts. You opt into as much of that as you need - a one-file syntactic codemod uses only the parser; a type-aware lint rule needs a full Program + checker. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#overview]
- The single most important framing fact - Strada vs Corsa: everything in this skill is the "Strada" API, the original JavaScript/TypeScript-based compiler. TS 6.0 (2026-03-23) is the final JS-based release. TS 7.0 "Corsa" is a ground-up Go port (≈10× faster) that **does not support the Strada compiler API - a replacement programmatic API is in progress and not stable as of mid-2026. So any tool you write against this surface targets TS ≤ 6.x**. ts-morph wraps Strada too, so it shares that ceiling. Plan migrations accordingly; don't assume your transformer/LS plugin carries to 7.x. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#overview]
- Version anchors (memorize - these drive most "does this API exist" questions): [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#overview]
- > Caveat: ts.createSourceFile survives because it is the parser entry point (text → tree), a > different thing from the removed factory ts.createXxx node builders. Don't be misled by the name > overlap. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#overview]
1. Two entry points: `createSourceFile` (parse only) vs `createProgram` (has a checker)
- ts.createSourceFile(fileName, text, langVersion, setParentNodes?) parses ONE in-memory string into a SourceFile. No types, no cross-file resolution, no checker. This is all a syntactic codemod/linter needs. Pass setParentNodes = true if you'll call node.getStart()/getText() (they need parent pointers - see Concept 5). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#1-two-entry-points-createsourcefile-parse-only-vs-createprogram-has-a-checker]
- ts.createProgram(rootFileNames, options, host?) builds a multi-file Program: it resolves imports, runs the binder, and is the only way to get a TypeChecker via program.getTypeChecker(). Use it for anything type-aware. options is a CompilerOptions (defer the option semantics to typescript-compiler-config). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#1-two-entry-points-createsourcefile-parse-only-vs-createprogram-has-a-checker]
2. The CompilerHost — controlling I/O
- createProgram's third arg is a CompilerHost: the abstraction the compiler uses to read files, resolve modules, and write output. ts.createCompilerHost(options) gives the default disk-backed host; override its methods to feed source from memory, a VFS, or a network, and to capture emit output instead of writing to disk. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#2-the-compilerhost-controlling-io]
3. Diagnostics
- ts.getPreEmitDiagnostics(program) → all syntactic + semantic + global errors before emit. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#3-diagnostics]
- program.emit() returns an EmitResult whose .diagnostics are emit-time errors; combine via ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#3-diagnostics]
- Format for humans: ts.formatDiagnosticsWithColorAndContext(diags, host) (ANSI, code frames) or ts.formatDiagnostics(diags, host) (plain). For a single message string use ts.flattenDiagnosticMessageText(d.messageText, "\n"). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#3-diagnostics]
4. Emitting JS
- program.emit(targetSourceFile?, writeFile?, cancellationToken?, emitOnlyDtsFiles?, customTransformers?) writes output through the host (or your writeFile callback). The 5th arg accepts { before, after, afterDeclarations } transformer arrays - this is how you run a transformer through the compiler (vs the standalone ts.transform, Concept 6). emitOnlyDtsFiles: true emits declarations only - but declaration-emit semantics and hand-authoring .d.ts are out of scope → typescript-declaration-files. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#4-emitting-js]
5. The AST: nodes, kinds, walking, positions, trivia
- A ts.Node has a numeric kind (ts.SyntaxKind enum). Narrow with type guards: ts.isFunctionDeclaration(node), ts.isCallExpression(node), ts.isIdentifier(node), etc. - these give correct TS narrowing, far better than raw kind === checks. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#5-the-ast-nodes-kinds-walking-positions-trivia]
- Walking - two different traversals, a classic codemod trap: [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#5-the-ast-nodes-kinds-walking-positions-trivia]
- ts.forEachChild(node, cb) visits only the semantically significant child nodes; it skips tokens, punctuation, and trivia. Use it for analysis/codemods. Returning a truthy value short-circuits (like Array.find). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#5-the-ast-nodes-kinds-walking-positions-trivia]
- node.getChildren(sourceFile?) returns every child including token nodes (braces, commas, keywords). Heavier; needed when you care about punctuation. Requires a parsed tree with parent pointers - throws on synthesized factory nodes. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#5-the-ast-nodes-kinds-walking-positions-trivia]
- Positions / text / trivia: node.getStart(sf) (start after leading trivia), node.pos (raw start, includes leading trivia), node.end, node.getText(sf), node.getFullText(sf) (with trivia), ts.getLeadingCommentRanges(fullText, node.pos) for comments. All of these need a real parsed SourceFile with setParentNodes/parents - on ts.factory-created nodes pos/end are -1 and these throw. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#5-the-ast-nodes-kinds-walking-positions-trivia]
6. The TypeChecker — resolving types and symbols
- The checker is where meaning lives. You must have a Program (a parse-only SourceFile has no checker). Core methods: [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
- checker.getTypeAtLocation(node) → the Type at any expression/decl node. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
- checker.getSymbolAtLocation(node) → the Symbol (declaration identity) for a name node. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
- checker.getTypeOfSymbolAtLocation(symbol, node) → a symbol's type in context (handles overloads/locations). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
- checker.typeToString(type) → human-readable type text (e.g. (name: string) => string). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
- Signatures: type.getCallSignatures() → Signature[]; sig.getReturnType(), sig.getParameters(). Symbols: symbol.getName(), symbol.valueDeclaration, checker.getDeclaredTypeOfSymbol(sym), checker.getPropertiesOfType(type). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#6-the-typechecker-resolving-types-and-symbols]
7. Custom transformers with `ts.factory`
- A TransformerFactory<T> is (context: ts.TransformationContext) => (node: T) => T. Inside, you recurse with ts.visitEachChild(node, visitor, context) (rewrites children) and return replacement nodes built with ts.factory.createXxx - the AST is immutable, so you create new nodes or update existing ones (ts.factory.updateXxx(original, ...newChildren) preserves position and emit info - prefer it over create when editing in place). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
- Run a transformer two ways: [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
- Standalone: ts.transform(sourceOrNodes, [transformer], options?) → TransformationResult; print with ts.createPrinter().printNode(...) or printFile(...). Call result.dispose(). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
- Through emit: pass { before: [t] } as the 5th arg to program.emit(...). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
- before runs before TS's built-in transforms, after runs after them (on downleveled output), afterDeclarations transforms the .d.ts tree. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
- > ts.visitNode visits a single node; ts.visitEachChild visits its children - you typically pair > them (top-level visitNode, recursive visitEachChild). To synthesize entirely new code, compose > ts.factory calls (e.g. ts.factory.createCallExpression(ts.factory.createIdentifier("log"), undefined, [arg])). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#7-custom-transformers-with-tsfactory]
8. Plugging transformers into a build — the `tsc` gap
- Vanilla tsc (the CLI) runs NO custom transformers. There is no tsconfig flag for it. Your options, from most to least direct: [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#8-plugging-transformers-into-a-build-the-tsc-gap]
- Programmatically - ts.transform or program.emit(…, { before, after }) (Concept 7). Full control; you own the build script. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#8-plugging-transformers-into-a-build-the-tsc-gap]
- Build-tool integration - most loaders accept transformers: ts-loader (options.getCustomTransformers), ts-jest, rollup-plugin-typescript2, etc. Bundlers using esbuild/swc do not run TS transformers (different engine) → nodejs-build-tooling-bundlers. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#8-plugging-transformers-into-a-build-the-tsc-gap]
- Patch tsc - ts-patch (the maintained successor to the older ttypescript) adds a plugins array under compilerOptions so tspc (its patched CLI) runs transformers during a normal build. Keys: transform (module path, required), after, afterDeclarations, transformProgram, import (named export), type. (Its persistent in-node_modules patch mode is "more limited in TypeScript 6+"; prefer the live tspc/ts-patch/compiler path.) [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#8-plugging-transformers-into-a-build-the-tsc-gap]
- > Do not confuse this with the native compilerOptions.plugins array - that one is Language Service > plugins only (Concept 9). Same JSON key, completely different mechanism. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#8-plugging-transformers-into-a-build-the-tsc-gap]
9. The Language Service + tsserver LS plugins
- The Language Service (ts.createLanguageService(host, registry?)) is the incremental, editor half of the compiler: it answers completions, quick-info (hover), diagnostics, go-to-definition, rename, and refactors. You feed it a LanguageServiceHost - like a CompilerHost but built for mutation: it must report file versions (bump the version string when a file changes) so the service re-checks only what moved. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#9-the-language-service-tsserver-ls-plugins]
- tsserver Language-Service plugins wrap this service to add editor features for everyone using the project (e.g. a framework's template-aware completions). You ship a module exporting function init({ typescript }) { return { create(info) { / wrap info.languageService / return proxy; } }; } and register it in tsconfig's native compilerOptions.plugins: [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#9-the-language-service-tsserver-ls-plugins]
- These run inside the editor's tsserver, not in tsc builds - they change the dev experience, not the emitted output. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#9-the-language-service-tsserver-ls-plugins]
10. ts-morph — the high-level wrapper
- ts-morph wraps the compiler API with a navigable, mutable object model so you skip the visitor/factory boilerplate. Use it for navigation, refactoring, and codegen ergonomics; drop to the raw API only when you need something it doesn't expose (then reach node.compilerNode for the underlying ts.Node, and project.getTypeChecker().compilerObject for the raw checker). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- new Project({ tsConfigFilePath }) (or useInMemoryFileSystem: true) is the root. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- Load: project.addSourceFilesAtPaths("src/**/*.ts"), addSourceFileAtPath(p), createSourceFile(path, text). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- Navigate: sourceFile.getFunctionOrThrow("name"), getClasses(), getDescendantsOfKind(SyntaxKind.CallExpression), node.getType().getText(). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- Manipulate: fn.rename("sum") (project-wide rename!), cls.addMethod({...}), node.replaceWithText(...), sourceFile.addImportDeclaration({...}). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- Persist: await project.save() writes changed files back. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
- Raw API vs ts-morph: raw is leaner (no extra dep), exact, and what you need for build-time transformers and LS plugins; ts-morph is faster to write for one-shot codemods, scaffolding/codegen, and bulk renames. Both target Strada (TS ≤ 6.x). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#10-ts-morph-the-high-level-wrapper]
11. typescript-eslint `parserServices` (pointer only)
- For type-aware lint rules, @typescript-eslint/parser (with parserOptions.project) attaches parserServices to each rule, exposing getTypeChecker() and esTreeNodeToTSNodeMap/tsNodeToESTreeNodeMap to bridge the ESLint ESTree node to the TS Node and its Type. That is the entry point for the whole typed-lint domain - authoring those rules is out of scope → typescript-eslint-typed-linting. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#11-typescript-eslint-parserservices-pointer-only]
Tools / Frameworks
- typescript (the package) - ts.createProgram, ts.createSourceFile, ts.createCompilerHost, program.getTypeChecker(), program.emit(), ts.transform, ts.createPrinter, ts.factory.*, ts.createLanguageService. Strada API; TS ≤ 6.x. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#tools-frameworks]
- ts-morph - high-level wrapper (Project, SourceFile, getDescendantsOfKind, rename, save); bundles its own TS (6.0.2 in v28). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#tools-frameworks]
- ts-patch (tspc) - successor to ttypescript; runs build transformers via compilerOptions.plugins. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#tools-frameworks]
- @typescript-eslint/parser parserServices - bridge to the checker for typed lint rules (defer rule authoring). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#tools-frameworks]
Methodology
- Pick the entry point by need. Syntactic-only (formatting, simple codemod) → createSourceFile (set setParentNodes if you read positions). Anything type-aware → createProgram + checker. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Choose raw vs ts-morph. One-shot codemod / scaffolding / bulk rename → ts-morph. Build-time transformer or LS plugin → raw API (no wrapper in the build path). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Walk with the right traversal. Analysis → forEachChild + ts.isXxx guards. Need tokens/punct → getChildren (parsed tree only). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Mutate immutably. Build with ts.factory.createXxx; prefer ts.factory.updateXxx when editing in place; recurse with visitEachChild; print with createPrinter. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Decide how it runs. Programmatic (ts.transform / emit), build-tool loader, or ts-patch. Never expect vanilla tsc to run it. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Read diagnostics via getPreEmitDiagnostics (+ emit diagnostics); format with formatDiagnosticsWithColorAndContext. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
- Mind the ceiling. This is Strada (TS ≤ 6.x); TS 7 "Corsa" won't run it - note that in any tool's compatibility docs. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#methodology]
Practical Patterns
- AST linter: parse-only createSourceFile → forEachChild + guards → collect { file, line, message } from getLineAndCharacterOfPosition(node.getStart(sf)). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
- Type extractor / API surface: createProgram → checker → for each exported symbol getTypeOfSymbolAtLocation + typeToString (and getCallSignatures) → dump JSON. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
- Codemod: TransformerFactory with ts.factory.updateXxx → ts.transform → printer.printFile → write back; or ts-morph getDescendantsOfKind + replaceWithText + project.save(). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
- Codegen: assemble brand-new files from ts.factory nodes, or project.createSourceFile(path, templateText) then refine via the model. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
- Build-plugged transform: author once, register under ts-patch compilerOptions.plugins (transform/after), build with tspc. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
- Editor feature: LanguageServiceHost with versioned snapshots → createLanguageService → getCompletionsAtPosition / getSemanticDiagnostics; ship as a tsserver plugin via native compilerOptions.plugins. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#practical-patterns]
Anti-Patterns
- Calling ts.createIdentifier / ts.createCall / ts.createNode / ts.updateXxx - removed in TS 5.0 (verified undefined in 5.8.3 and 6.0.3). Always ts.factory.createXxx / updateXxx. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Mutating node fields in place - the AST is immutable; create or update nodes instead. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Reading getStart/getText/getChildren/positions on ts.factory-synthesized nodes (pos/end = -1) - they throw; those need a parsed tree with parent pointers (setParentNodes). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Confusing forEachChild (named children, no tokens) with getChildren() (all tokens) - picking the wrong one silently skips or floods nodes in a codemod. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Expecting vanilla tsc to run a transformer - it never does; use programmatic emit, a loader, or ts-patch. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Conflating the two plugins arrays: native compilerOptions.plugins = LS/editor plugins (tsc ignores); ts-patch's compilerOptions.plugins (with transform) = build transformers. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Asking getTypeChecker() on a parse-only SourceFile - there's no checker without a Program. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
- Assuming compiler-API tooling (or ts-morph) survives the move to TS 7 "Corsa" - Strada API is dropped; budget a rewrite. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#anti-patterns]
Troubleshooting
- ts.createXxx is not a function → removed in 5.0; switch to ts.factory.createXxx. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
- Cannot read properties of undefined (reading 'getStart'/'pos') or -1 positions → node is synthesized (factory) or you parsed without setParentNodes; re-parse with parents or don't read positions off synthetic nodes. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
- Checker returns any/undefined symbols → the file isn't in the Program's root set, or imports didn't resolve (check CompilerOptions.module/moduleResolution, or a custom host's readFile). [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
- Transformer "did nothing" under tsc → vanilla tsc ignores transformers; run via ts.transform, program.emit({before}), a loader, or tspc. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
- LS plugin not loading → it only runs in the editor's tsserver, not tsc; confirm the editor uses the workspace TS version and the plugin name resolves. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
- getCompletionsAtPosition stale after edits → bump the file's getScriptVersion string so the Language Service invalidates its cache. [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#troubleshooting]
References
- TS wiki - Using the Compiler API: https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- typescript package source / API (probed at runtime, 6.0.3 / 5.8.3 / 4.9.5): https://github.com/microsoft/TypeScript [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- ts-morph docs (bundles ts 6.0.2): https://ts-morph.com/ [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- ts-patch (successor to ttypescript; compilerOptions.plugins): https://github.com/nonara/ts-patch [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- MS DevBlogs - Progress on TypeScript 7 ("Corsa", Dec 2025): https://devblogs.microsoft.com/typescript/progress-on-typescript-7-december-2025/ [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- VS Magazine - TS 6.0 ships as final JS-based release (2026-03-23): https://visualstudiomagazine.com/articles/2026/03/23/typescript-6-0-ships-as-final-javascript-based-release-clears-path-for-go-native-7-0.aspx [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
- typescript-eslint - parserServices / typed linting: https://typescript-eslint.io/getting-started/typed-linting/ [archived source: https://llms-explorer.com/sources/mdb-context-hub/typescript-compiler-api/#references]
Where this helps
- Building a custom codemod or AST-based linter that needs to walk and rewrite TypeScript source programmatically instead of via regex. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Building a type-extraction tool that dumps a package's exported API surface (types, signatures) as JSON for documentation or compatibility checking. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Deciding whether to use the raw Compiler API or ts-morph for a one-off bulk rename versus a build-time transformer. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Debugging why a custom transformer registered under vanilla tsc silently does nothing, since tsc never runs custom transformers. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
Project ideas
- Build an AST-based linter using createSourceFile (parse-only) plus forEachChild and ts.isXxx type guards to flag a specific coding pattern across a codebase. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Build a type-extractor that walks a Program's exported symbols with the TypeChecker and dumps each one's typeToString() output as a JSON API-surface report. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Build a codemod using ts.factory node builders and ts.transform, then wire it into a real build via ts-patch since vanilla tsc never runs custom transformers. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Build a bulk-rename or scaffolding tool with ts-morph's Project/SourceFile API instead of hand-rolling factory/visitor boilerplate for a one-shot task. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
Common mistakes
- Calling removed factory functions like ts.createIdentifier or ts.createCall instead of the current ts.factory.createXxx / updateXxx API - these were removed in TS 5.0. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Confusing forEachChild (semantically significant children only) with getChildren() (every token including punctuation) - picking the wrong traversal silently skips or floods nodes in a codemod. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Reading getStart/getText/positions off a synthesized ts.factory node - those have pos/end = -1 and throw, since they need a parsed tree with parent pointers. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- Expecting vanilla tsc to run a registered custom transformer - it never does; transformers only run through programmatic emit, a build-tool loader, or ts-patch. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
Known issues
- The entire raw Compiler API described here is the "Strada" (JavaScript-based) API; TypeScript 7 "Corsa" (the Go-native port) drops the Strada API entirely, so compiler-API tooling and ts-morph will need a rewrite to survive that migration. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- ts.createProgram must resolve every import correctly (via CompilerOptions.module/moduleResolution or a custom host) or the TypeChecker silently returns any/undefined for unresolved symbols. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- A tsserver Language-Service plugin only runs inside the editor's tsserver process - it has zero effect on a tsc build, a distinction that's easy to conflate with build-time transformers. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
- ts-morph bundles its own pinned TypeScript version internally, so its behavior can diverge slightly from whatever TypeScript version the rest of the project uses. [source] — AI-suggested, synthesized from this pack's existing facts — not extracted from a source document.
Children
- No children recorded.