Skip to content

Commit ef436a1

Browse files
committed
PR Feedback
1 parent 47ae027 commit ef436a1

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/compiler/printer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const _super = (function (geti, seti) {
169169
const printStart = performance.mark();
170170

171171
// Emit each output file
172-
forEachEmitFile(host, transformed.getSourceFiles(), emitFile);
172+
forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile);
173173

174174
// Clean up after transformation
175175
transformed.dispose();
@@ -220,7 +220,7 @@ const _super = (function (geti, seti) {
220220
forEach(sourceFiles, emitEmitHelpers);
221221
}
222222

223-
// Transform and print the source files
223+
// Print each transformed source file.
224224
forEach(sourceFiles, printSourceFile);
225225

226226
writeLine();

src/compiler/utilities.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ namespace ts {
300300
return getTokenPosOfNode(node.jsDocComments[0]);
301301
}
302302

303-
// For a syntax list, it is possible that one of its children has JSDocComment nodes, while
304-
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
303+
// For a syntax list, it is possible that one of its children has JSDocComment nodes, while
304+
// the syntax list itself considers them as normal trivia. Therefore if we simply skip
305305
// trivia for the list, we may have skipped the JSDocComment as well. So we should process its
306306
// first child to determine the actual position of its first token.
307307
if (node.kind === SyntaxKind.SyntaxList && (<SyntaxList>node)._children.length > 0) {
@@ -2485,6 +2485,15 @@ namespace ts {
24852485
declarationFilePath: string;
24862486
}
24872487

2488+
/**
2489+
* Gets the source files that are expected to have an emit output.
2490+
*
2491+
* Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support
2492+
* transformations.
2493+
*
2494+
* @param host An EmitHost.
2495+
* @param targetSourceFile An optional target source file to emit.
2496+
*/
24882497
export function getSourceFilesToEmit(host: EmitHost, targetSourceFile?: SourceFile) {
24892498
const options = host.getCompilerOptions();
24902499
if (options.outFile || options.out) {
@@ -2508,7 +2517,18 @@ namespace ts {
25082517
return !isDeclarationFile(sourceFile) && !isExternalModule(sourceFile);
25092518
}
25102519

2511-
export function forEachEmitFile(host: EmitHost, sourceFiles: SourceFile[],
2520+
/**
2521+
* Iterates over each source file to emit. The source files are expected to have been
2522+
* transformed for use by the pretty printer.
2523+
*
2524+
* Originally part of `forEachExpectedEmitFile`, this functionality was extracted to support
2525+
* transformations.
2526+
*
2527+
* @param host An EmitHost.
2528+
* @param sourceFiles The transformed source files to emit.
2529+
* @param action The action to execute.
2530+
*/
2531+
export function forEachTransformedEmitFile(host: EmitHost, sourceFiles: SourceFile[],
25122532
action: (jsFilePath: string, sourceMapFilePath: string, declarationFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) => void) {
25132533
const options = host.getCompilerOptions();
25142534
// Emit on each source file
@@ -2559,6 +2579,15 @@ namespace ts {
25592579
return options.sourceMap ? jsFilePath + ".map" : undefined;
25602580
}
25612581

2582+
/**
2583+
* Iterates over the source files that are expected to have an emit output. This function
2584+
* is used by the legacy emitter and the declaration emitter and should not be used by
2585+
* the tree transforming emitter.
2586+
*
2587+
* @param host An EmitHost.
2588+
* @param action The action to execute.
2589+
* @param targetSourceFile An optional target source file to emit.
2590+
*/
25622591
export function forEachExpectedEmitFile(host: EmitHost,
25632592
action: (emitFileNames: EmitFileNames, sourceFiles: SourceFile[], isBundledEmit: boolean) => void,
25642593
targetSourceFile?: SourceFile) {

0 commit comments

Comments
 (0)