Skip to content

Commit 2cbe14e

Browse files
committed
Respond to code review comments
1 parent e7eef83 commit 2cbe14e

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ module ts {
286286
}
287287
}
288288

289-
function getCompilerOptionsDiagnostics(): Diagnostic[]{
289+
function getCompilerOptionsDiagnostics(): Diagnostic[] {
290290
let allDiagnostics: Diagnostic[] = [];
291291
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
292292
return sortAndDeduplicateDiagnostics(allDiagnostics);

src/services/services.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,8 @@ module ts {
17631763
* Extra compiler options that will unconditionally be used bu this function are:
17641764
* - isolatedModules = true
17651765
* - allowNonTsExtensions = true
1766+
* - noLib = true
1767+
* - noResolve = true
17661768
*/
17671769
export function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[]): string {
17681770
let options = compilerOptions ? clone(compilerOptions) : getDefaultCompilerOptions();
@@ -1772,11 +1774,12 @@ module ts {
17721774
// Filename can be non-ts file.
17731775
options.allowNonTsExtensions = true;
17741776

1775-
// We are not returning a lib file when asked, so pass this flag to
1776-
// avoid reporting a file not found error
1777+
// We are not returning a sourceFile for lib file when asked by the program,
1778+
// so pass --noLib to avoid reporting a file not found error.
17771779
options.noLib = true;
17781780

1779-
// Similar to the library, we are not returning any refrenced files
1781+
// We are not doing a full typecheck, we are not resolving the whole context,
1782+
// so pass --noResolve to avoid reporting missing file errors.
17801783
options.noResolve = true;
17811784

17821785
// Parse

tests/cases/unittests/transpile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ module ts {
77
let diagnostics: Diagnostic[] = [];
88
let result = transpile(input, compilerOptions, "file.ts", diagnostics);
99

10-
assert.equal(diagnostics.length, expectedDiagnosticCodes.length);
11-
for (let diagnostic of diagnostics) {
12-
assert.isTrue(expectedDiagnosticCodes.indexOf(diagnostic.code) >= 0, `Found an unexpected diagnostic: ${ diagnostic.code }`);
10+
for (let i = 0; i < expectedDiagnosticCodes.length; i++) {
11+
assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`);
1312
}
13+
assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected");
1414

1515
if (expectedOutput !== undefined) {
1616
assert.equal(result, expectedOutput);

0 commit comments

Comments
 (0)