mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Respond to code review comments
This commit is contained in:
parent
e7eef830e1
commit
2cbe14e131
@ -286,7 +286,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getCompilerOptionsDiagnostics(): Diagnostic[]{
|
||||
function getCompilerOptionsDiagnostics(): Diagnostic[] {
|
||||
let allDiagnostics: Diagnostic[] = [];
|
||||
addRange(allDiagnostics, diagnostics.getGlobalDiagnostics());
|
||||
return sortAndDeduplicateDiagnostics(allDiagnostics);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user