Address PR: give default value for getDefaultLibrarySourceFile and use debug assert

This commit is contained in:
Kanchalai Tanglertsampan
2016-03-28 16:55:00 -07:00
parent 7f8774f68e
commit 99f9efb169
2 changed files with 5 additions and 4 deletions

View File

@@ -292,7 +292,7 @@ namespace FourSlash {
// Check if no-default-lib flag is false and if so add default library
if (!resolvedResult.isLibFile) {
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName,
Harness.Compiler.getDefaultLibrarySourceFile(Harness.Compiler.defaultLibFileName).text);
Harness.Compiler.getDefaultLibrarySourceFile().text);
}
}
else {
@@ -303,7 +303,7 @@ namespace FourSlash {
}
});
this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName,
Harness.Compiler.getDefaultLibrarySourceFile(Harness.Compiler.defaultLibFileName).text);
Harness.Compiler.getDefaultLibrarySourceFile().text);
}
this.formatCodeOptions = {

View File

@@ -815,8 +815,9 @@ namespace Harness {
[defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest)
};
export function getDefaultLibrarySourceFile(fileName: string): ts.SourceFile {
export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile {
if (!isLibraryFile(fileName)) {
assert(!isLibraryFile(fileName), "Expected library fileName");
return undefined;
}
@@ -827,7 +828,7 @@ namespace Harness {
}
export function getDefaultLibSourceFile(languageVersion: ts.ScriptTarget) {
return languageVersion === ts.ScriptTarget.ES6 ? getDefaultLibrarySourceFile("lib.es2015.d.ts") : getDefaultLibrarySourceFile(defaultLibFileName);
return languageVersion === ts.ScriptTarget.ES6 ? getDefaultLibrarySourceFile(es2015DefaultLibFileName) : getDefaultLibrarySourceFile(defaultLibFileName);
}
// Cache these between executions so we don't have to re-parse them for every test