Make TransformationContext.getCompilerOptions public
This commit is contained in:
parent
6c59ee4ce6
commit
1bbaaa3831
2 changed files with 13 additions and 11 deletions
|
@ -3826,10 +3826,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TransformationContext {
|
export interface TransformationContext {
|
||||||
/*@internal*/ getCompilerOptions(): CompilerOptions;
|
|
||||||
/*@internal*/ getEmitResolver(): EmitResolver;
|
/*@internal*/ getEmitResolver(): EmitResolver;
|
||||||
/*@internal*/ getEmitHost(): EmitHost;
|
/*@internal*/ getEmitHost(): EmitHost;
|
||||||
|
|
||||||
|
/** Gets the compiler options supplied to the transformer. */
|
||||||
|
getCompilerOptions(): CompilerOptions;
|
||||||
|
|
||||||
/** Starts a new lexical environment. */
|
/** Starts a new lexical environment. */
|
||||||
startLexicalEnvironment(): void;
|
startLexicalEnvironment(): void;
|
||||||
|
|
||||||
|
@ -3892,11 +3894,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TransformationResult {
|
export interface TransformationResult {
|
||||||
/**
|
/** Gets the transformed source files. */
|
||||||
* Gets the transformed source files.
|
|
||||||
*/
|
|
||||||
transformed: SourceFile[];
|
transformed: SourceFile[];
|
||||||
|
|
||||||
|
/** Gets diagnostics for the transformation. */
|
||||||
|
diagnostics?: Diagnostic[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits the substitute for a node, if one is available; otherwise, emits the node.
|
* Emits the substitute for a node, if one is available; otherwise, emits the node.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
/// <reference path="..\compiler\transformer.ts"/>
|
/// <reference path="..\compiler\transformer.ts"/>
|
||||||
/// <reference path="transpile.ts"/>
|
/// <reference path="transpile.ts"/>
|
||||||
namespace ts {
|
namespace ts {
|
||||||
export interface TransformOptions {
|
|
||||||
newLine?: NewLineKind;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform one or more source files using the supplied transformers.
|
* Transform one or more source files using the supplied transformers.
|
||||||
* @param source A `SourceFile` or an array of `SourceFiles`.
|
* @param source A `SourceFile` or an array of `SourceFiles`.
|
||||||
* @param transformers An array of `Transformer` callbacks used to process the transformation.
|
* @param transformers An array of `Transformer` callbacks used to process the transformation.
|
||||||
* @param compilerOptions Optional compiler options.
|
* @param compilerOptions Optional compiler options.
|
||||||
*/
|
*/
|
||||||
export function transform(source: SourceFile | SourceFile[], transformers: Transformer[], transformOptions?: TransformOptions) {
|
export function transform(source: SourceFile | SourceFile[], transformers: Transformer[], compilerOptions?: CompilerOptions) {
|
||||||
const compilerOptions = <CompilerOptions>transformOptions || {};
|
const diagnostics: Diagnostic[] = [];
|
||||||
|
compilerOptions = fixupCompilerOptions(compilerOptions, diagnostics);
|
||||||
const newLine = getNewLineCharacter(compilerOptions);
|
const newLine = getNewLineCharacter(compilerOptions);
|
||||||
const sourceFiles = isArray(source) ? source : [source];
|
const sourceFiles = isArray(source) ? source : [source];
|
||||||
const fileMap = arrayToMap(sourceFiles, sourceFile => sourceFile.fileName);
|
const fileMap = arrayToMap(sourceFiles, sourceFile => sourceFile.fileName);
|
||||||
|
@ -29,6 +26,8 @@ namespace ts {
|
||||||
isEmitBlocked: () => false,
|
isEmitBlocked: () => false,
|
||||||
writeFile: () => Debug.fail("'writeFile()' is not supported during transformation.")
|
writeFile: () => Debug.fail("'writeFile()' is not supported during transformation.")
|
||||||
};
|
};
|
||||||
return transformFiles(/*resolver*/ undefined, emitHost, sourceFiles, transformers);
|
const result = transformFiles(/*resolver*/ undefined, emitHost, sourceFiles, transformers);
|
||||||
|
result.diagnostics = concatenate(result.diagnostics, diagnostics);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue