1
1
/// <reference path="..\compiler\transformer.ts"/>
2
2
/// <reference path="transpile.ts"/>
3
3
namespace ts {
4
- export interface TransformOptions {
5
- newLine ?: NewLineKind ;
6
- }
7
-
8
4
/**
9
5
* Transform one or more source files using the supplied transformers.
10
6
* @param source A `SourceFile` or an array of `SourceFiles`.
11
7
* @param transformers An array of `Transformer` callbacks used to process the transformation.
12
8
* @param compilerOptions Optional compiler options.
13
9
*/
14
- export function transform ( source : SourceFile | SourceFile [ ] , transformers : Transformer [ ] , transformOptions ?: TransformOptions ) {
15
- const compilerOptions = < CompilerOptions > transformOptions || { } ;
10
+ export function transform ( source : SourceFile | SourceFile [ ] , transformers : Transformer [ ] , compilerOptions ?: CompilerOptions ) {
11
+ const diagnostics : Diagnostic [ ] = [ ] ;
12
+ compilerOptions = fixupCompilerOptions ( compilerOptions , diagnostics ) ;
16
13
const newLine = getNewLineCharacter ( compilerOptions ) ;
17
14
const sourceFiles = isArray ( source ) ? source : [ source ] ;
18
15
const fileMap = arrayToMap ( sourceFiles , sourceFile => sourceFile . fileName ) ;
@@ -29,6 +26,8 @@ namespace ts {
29
26
isEmitBlocked : ( ) => false ,
30
27
writeFile : ( ) => Debug . fail ( "'writeFile()' is not supported during transformation." )
31
28
} ;
32
- return transformFiles ( /*resolver*/ undefined , emitHost , sourceFiles , transformers ) ;
29
+ const result = transformFiles ( /*resolver*/ undefined , emitHost , sourceFiles , transformers ) ;
30
+ result . diagnostics = concatenate ( result . diagnostics , diagnostics ) ;
31
+ return result ;
33
32
}
34
33
}
0 commit comments