Respond to code review comments

This commit is contained in:
Mohamed Hegazy 2015-05-27 10:20:01 -07:00
parent e7eef830e1
commit 2cbe14e131
3 changed files with 10 additions and 7 deletions

View File

@ -286,7 +286,7 @@ module ts {
}
}
function getCompilerOptionsDiagnostics(): Diagnostic[]{
function getCompilerOptionsDiagnostics(): Diagnostic[] {
let allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
return sortAndDeduplicateDiagnostics(allDiagnostics);

View File

@ -1763,6 +1763,8 @@ module ts {
* Extra compiler options that will unconditionally be used bu this function are:
* - isolatedModules = true
* - allowNonTsExtensions = true
* - noLib = true
* - noResolve = true
*/
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
@ -1772,11 +1774,12 @@ module ts {
// Filename can be non-ts file.
options.allowNonTsExtensions = true;
// We are not returning a lib file when asked, so pass this flag to
// avoid reporting a file not found error
// We are not returning a sourceFile for lib file when asked by the program,
// so pass --noLib to avoid reporting a file not found error.
options.noLib = true;
// Similar to the library, we are not returning any refrenced files
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
// Parse

View File

@ -7,10 +7,10 @@ module ts {
let diagnostics: Diagnostic[] = [];
let result = transpile(input, compilerOptions, "file.ts", diagnostics);
assert.equal(diagnostics.length, expectedDiagnosticCodes.length);
for (let diagnostic of diagnostics) {
assert.isTrue(expectedDiagnosticCodes.indexOf(diagnostic.code) >= 0, `Found an unexpected diagnostic: ${ diagnostic.code }`);
for (let i = 0; i < expectedDiagnosticCodes.length; i++) {
assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`);
}
assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected");
if (expectedOutput !== undefined) {
assert.equal(result, expectedOutput);