-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Codebase Compiler Emitter
The emitter is a tree based syntax emitter. It works by going through the TypeScript AST for a program and emitting source code as it is pipelined.
The emitter itself is "dumb" in the sense that it doesn't contain logic outside of printing whatever AST it is given. So, it's possible that a bug in emission is actually that the AST isn't set up the way that you'd like it.
Creating a single file which represents many is done by creating a SyntaxKind.Bundle
. Printing happens in
function writeBundle(
. There are prepends
which I don't understand, and then each sourcefile is is
printed.
The printer is a part of the emitter, you create one with createPrinter
, then start calling print
with an AST node on it. This adds the node via a pipeline:
const enum PipelinePhase {
Notification,
Substitution,
Comments,
SourceMaps,
Emit,
}
With the word to start emitting through the AST in [pipelineEmitWithHint
][4]. There is a hint option which can
be used to force the emit type.
The process of changing your AST into the expected JS or TS happens the emitter compiler transformers. There is a full step
Emitting a declaration file is a multi-step process. It goes through the above emitter of its AST, but then also goes through a
News
Debugging TypeScript
- Performance
- Performance-Tracing
- Debugging-Language-Service-in-VS-Code
- Getting-logs-from-TS-Server-in-VS-Code
- JavaScript-Language-Service-in-Visual-Studio
- Providing-Visual-Studio-Repro-Steps
Contributing to TypeScript
- Contributing to TypeScript
- TypeScript Design Goals
- Coding Guidelines
- Useful Links for TypeScript Issue Management
- Writing Good Design Proposals
- Compiler Repo Notes
- Deployment
Building Tools for TypeScript
- Architectural Overview
- Using the Compiler API
- Using the Language Service API
- Standalone Server (tsserver)
- TypeScript MSBuild In Depth
- Debugging Language Service in VS Code
- Writing a Language Service Plugin
- Docker Quickstart
FAQs
The Main Repo