Skip to content

Commit 9a65a66

Browse files
committedFeb 5, 2017
Fix linter error
1 parent bd98bc9 commit 9a65a66

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
 

‎src/compiler/visitor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ namespace ts {
587587
}
588588
if (visited) {
589589
if (isArray(visited)) {
590-
for (let visitedNode of visited) {
590+
for (const visitedNode of visited) {
591591
Debug.assertNode(visitedNode, test);
592592
aggregateTransformFlags(visitedNode);
593593
updated.push(<T>visitedNode);

‎src/services/transform.ts

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path="..\compiler\transformer.ts"/>
2+
/// <reference path="transpile.ts"/>
3+
namespace ts {
4+
/**
5+
* Transform one or more source files using the supplied transformers.
6+
* @param source A `SourceFile` or an array of `SourceFiles`.
7+
* @param transformers An array of `Transformer` callbacks used to process the transformation.
8+
*/
9+
export function transform(source: SourceFile | SourceFile[], transformers: Transformer[]) {
10+
const diagnostics: Diagnostic[] = [];
11+
const compilerOptions: CompilerOptions = {};
12+
const sourceFiles = isArray(source) ? source : [source];
13+
const fileMap = arrayToMap(sourceFiles, sourceFile => sourceFile.fileName);
14+
const emitHost: EmitHost = {
15+
getCompilerOptions: () => compilerOptions,
16+
getCanonicalFileName: fileName => fileName,
17+
getCommonSourceDirectory: () => "",
18+
getCurrentDirectory: () => "",
19+
getNewLine: () => "\n",
20+
getSourceFile: fileName => fileMap.get(fileName),
21+
getSourceFileByPath: fileName => fileMap.get(fileName),
22+
getSourceFiles: () => sourceFiles,
23+
isSourceFileFromExternalLibrary: () => false,
24+
isEmitBlocked: () => false,
25+
writeFile: () => Debug.fail("'writeFile()' is not supported during transformation.")
26+
};
27+
return transformFiles(/*resolver*/ undefined, emitHost, sourceFiles, transformers);
28+
}
29+
}

0 commit comments

Comments
 (0)
Please sign in to comment.