Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Codebase Compiler Emitter

Nathan Shively-Sanders edited this pageSep 2, 2022 ·1 revision

Emitter

The emitter is a tree based syntax emitter. It works by going through the TypeScript AST for a program andemitting 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 isgiven. 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.

Outfile

Creating a single file which represents many is done by creating aSyntaxKind.Bundle. Printing happens infunction writeBundle(. There areprepends which I don't understand, and then each sourcefile is isprinted.

Printer

The printer is a part of the emitter, you create one withcreatePrinter, then start callingprintwith an AST node on it. This adds the node via apipeline:

constenumPipelinePhase{Notification,Substitution,Comments,SourceMaps,Emit,}

With the word to start emitting through the AST in [pipelineEmitWithHint][4]. There is a hint option which canbe used to force the emit type.

Post Processing via Transformers

The process of changing your AST into the expected JS or TS happens the emitter compiler transformers. There is afull step

Emitting a declaration file is a multi-step process. It goes through the above emitter of its AST, but thenalsogoes through a

Want to contribute to this Wiki?

Fork it and send a pull request.

News

Debugging TypeScript

Contributing to TypeScript

Building Tools for TypeScript

FAQs

The Main Repo

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp