Fix linter error

This commit is contained in:
Ron Buckton
2017-02-04 22:46:38 -08:00
parent bd98bc97bd
commit 9a65a66423
2 changed files with 30 additions and 1 deletions

View File

@@ -587,7 +587,7 @@ namespace ts {
}
if (visited) {
if (isArray(visited)) {
for (let visitedNode of visited) {
for (const visitedNode of visited) {
Debug.assertNode(visitedNode, test);
aggregateTransformFlags(visitedNode);
updated.push(<T>visitedNode);

29
src/services/transform.ts Normal file
View File

@@ -0,0 +1,29 @@
/// <reference path="..\compiler\transformer.ts"/>
/// <reference path="transpile.ts"/>
namespace ts {
/**
* Transform one or more source files using the supplied transformers.
* @param source A `SourceFile` or an array of `SourceFiles`.
* @param transformers An array of `Transformer` callbacks used to process the transformation.
*/
export function transform(source: SourceFile | SourceFile[], transformers: Transformer[]) {
const diagnostics: Diagnostic[] = [];
const compilerOptions: CompilerOptions = {};
const sourceFiles = isArray(source) ? source : [source];
const fileMap = arrayToMap(sourceFiles, sourceFile => sourceFile.fileName);
const emitHost: EmitHost = {
getCompilerOptions: () => compilerOptions,
getCanonicalFileName: fileName => fileName,
getCommonSourceDirectory: () => "",
getCurrentDirectory: () => "",
getNewLine: () => "\n",
getSourceFile: fileName => fileMap.get(fileName),
getSourceFileByPath: fileName => fileMap.get(fileName),
getSourceFiles: () => sourceFiles,
isSourceFileFromExternalLibrary: () => false,
isEmitBlocked: () => false,
writeFile: () => Debug.fail("'writeFile()' is not supported during transformation.")
};
return transformFiles(/*resolver*/ undefined, emitHost, sourceFiles, transformers);
}
}