Skip to content

Commit 94e788c

Browse files
author
Yui T
committed
Address code review
1 parent 76656f2 commit 94e788c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/compiler/tsc.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ module ts {
199199

200200
export function executeCommandLine(args: string[]): void {
201201
var commandLine = parseCommandLine(args);
202+
var compilerOptions = commandLine.options;
202203

203-
if (commandLine.options.locale) {
204+
if (compilerOptions.locale) {
204205
validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors);
205206
}
206207

@@ -211,20 +212,26 @@ module ts {
211212
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
212213
}
213214

214-
if (commandLine.options.version) {
215+
if (compilerOptions.version) {
215216
reportDiagnostic(createCompilerDiagnostic(Diagnostics.Version_0, version));
216-
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
217+
return sys.exit(EmitReturnStatus.Succeeded);
218+
}
219+
220+
if (compilerOptions.help) {
221+
printVersion();
222+
printHelp();
223+
return sys.exit(EmitReturnStatus.Succeeded);
217224
}
218225

219-
if (commandLine.options.help || commandLine.filenames.length === 0) {
226+
if (commandLine.filenames.length === 0) {
220227
printVersion();
221228
printHelp();
222229
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
223230
}
224231

225-
var defaultCompilerHost = createCompilerHost(commandLine.options);
232+
var defaultCompilerHost = createCompilerHost(compilerOptions);
226233

227-
if (commandLine.options.watch) {
234+
if (compilerOptions.watch) {
228235
if (!sys.watchFile) {
229236
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
230237
return sys.exit(EmitReturnStatus.CompilerOptionsErrors);
@@ -332,14 +339,14 @@ module ts {
332339
var program = createProgram(commandLine.filenames, compilerOptions, compilerHost);
333340

334341
var bindStart = new Date().getTime();
335-
var syntacticErrors = program.getDiagnostics();
336-
var errors: Diagnostic[];
342+
var errors: Diagnostic[] = program.getDiagnostics();
337343
var exitStatus: EmitReturnStatus;
338344

339-
if (syntacticErrors.length) {
345+
if (errors.length) {
340346
var checkStart = bindStart;
341347
var emitStart = bindStart;
342348
var reportStart = bindStart;
349+
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
343350
}
344351
else {
345352
var checker = program.getTypeChecker(/*fullTypeCheckMode*/ true);
@@ -350,7 +357,7 @@ module ts {
350357
var emitErrors = emitOutput.errors;
351358
exitStatus = emitOutput.emitResultStatus;
352359
var reportStart = new Date().getTime();
353-
errors = concatenate(syntacticErrors, concatenate(semanticErrors, emitErrors));
360+
errors = concatenate(semanticErrors, emitErrors);
354361
}
355362

356363
reportDiagnostics(errors);
@@ -372,10 +379,6 @@ module ts {
372379
reportTimeStatistic("Total time", reportStart - parseStart);
373380
}
374381

375-
// Check if there exists syntactic errors
376-
if (syntacticErrors.length > 0) {
377-
exitStatus = EmitReturnStatus.AllOutputGenerationSkipped;
378-
}
379382
return { program: program, exitStatus: exitStatus }
380383
}
381384

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,11 +603,11 @@ module ts {
603603
// Return code used by getEmitOutput function to indicate status of the function
604604
export enum EmitReturnStatus {
605605
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
606-
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
606+
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, nothing generated
607607
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
608608
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
609609
EmitErrorsEncountered = 4, // Emitter errors occurred during emitting process
610-
CompilerOptionsErrors = 5, // Errors occurred in parsing compiler options
610+
CompilerOptionsErrors = 5, // Errors occurred in parsing compiler options, nothing generated
611611
}
612612

613613
export interface EmitResult {

0 commit comments

Comments
 (0)