11.09.2015 Views

Typescript Deep Dive by Basarat Ali Syed

Typescript Deep Dive by Basarat Ali Syed

Typescript Deep Dive by Basarat Ali Syed

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TypeScript <strong>Deep</strong> <strong>Dive</strong><br />

Emitter<br />

There are two emitters provided with the TypeScript compiler:<br />

emitter.ts : this is the emitter you are most likely to be interested in. Its the TS -> JavaScript emitter.<br />

declarationEmitter.ts : this is the emitter used to create a declaration file (a .d.ts ) for a TypeScript source file (a .ts<br />

file).<br />

We will look at emitter.ts in this section.<br />

Usage <strong>by</strong> program<br />

Program provides an emit function. This function primarily delegates to emitFiles function in emitter.ts . Here is the call<br />

stack:<br />

Program.emit -><br />

`emitWorker` (local in program.ts createProgram) -><br />

`emitFiles` (function in emitter.ts)<br />

One thing that the emitWorker provides to the emitter (via an argument to emitFiles ) is an EmitResolver . EmitResolver is<br />

provided <strong>by</strong> the program's TypeChecker, basically it a subset of local functions from createChecker .<br />

Emitter<br />

95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!