Simplify the createProgram API.

Allow the host parameter to be optional to simplify command line programs.
This commit is contained in:
Cyrus Najmabadi
2015-02-04 17:02:26 -08:00
parent bb307f8163
commit 2a1d78d9e3
10 changed files with 23 additions and 34 deletions

View File

@@ -73,13 +73,14 @@ module ts {
};
}
export function createProgram(rootNames: string[], options: CompilerOptions, host: CompilerHost): Program {
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program {
var program: Program;
var files: SourceFile[] = [];
var filesByName: Map<SourceFile> = {};
var errors: Diagnostic[] = [];
var seenNoDefaultLib = options.noLib;
var commonSourceDirectory: string;
host = host || createCompilerHost(options);
forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {