From c5657a353177c8cb9912b8266989b3c7f506e35b Mon Sep 17 00:00:00 2001 From: Dafrok Date: Mon, 19 Sep 2016 11:51:34 +0800 Subject: [PATCH 1/3] Output the help message line by line. --- src/compiler/tsc.ts | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 916d32841a47c..497ed4ed224a6 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -667,7 +667,7 @@ namespace ts { } function printHelp() { - let output = ""; + const output = []; // We want to align our "syntax" and "examples" commands to a certain margin. const syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; @@ -678,17 +678,17 @@ namespace ts { let syntax = makePadding(marginLength - syntaxLength); syntax += "tsc [" + getDiagnosticText(Diagnostics.options) + "] [" + getDiagnosticText(Diagnostics.file) + " ...]"; - output += getDiagnosticText(Diagnostics.Syntax_Colon_0, syntax); - output += sys.newLine + sys.newLine; + output.push(getDiagnosticText(Diagnostics.Syntax_Colon_0, syntax)); + output.push(sys.newLine + sys.newLine); // Build up the list of examples. const padding = makePadding(marginLength); - output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine; - output += padding + "tsc --outFile file.js file.ts" + sys.newLine; - output += padding + "tsc @args.txt" + sys.newLine; - output += sys.newLine; + output.push(getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine); + output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine); + output.push(padding + "tsc @args.txt" + sys.newLine); + output.push(sys.newLine); - output += getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine; + output.push(getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine); // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") const optsList = filter(optionDeclarations.slice(), v => !v.experimental); @@ -755,18 +755,19 @@ namespace ts { const usage = usageColumn[i]; const description = descriptionColumn[i]; const kindsList = optionsDescriptionMap[description]; - output += usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine; + output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine); if (kindsList) { - output += makePadding(marginLength + 4); + output.push(makePadding(marginLength + 4)); for (const kind of kindsList) { - output += kind + " "; + output.push(kind + " "); } - output += sys.newLine; + output.push(sys.newLine); } } - - sys.write(output); + output.forEach(function (val) { + sys.write(val); + }) return; function getParamType(option: CommandLineOption) { From 056662de7cd9aa12c21ef27ddfee2ee49b8d7400 Mon Sep 17 00:00:00 2001 From: Dafrok Date: Mon, 19 Sep 2016 13:48:01 +0800 Subject: [PATCH 2/3] Pass the jake test --- src/compiler/tsc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 497ed4ed224a6..7cf8864d35785 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -667,7 +667,7 @@ namespace ts { } function printHelp() { - const output = []; + const output: any = []; // We want to align our "syntax" and "examples" commands to a certain margin. const syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; @@ -765,9 +765,9 @@ namespace ts { output.push(sys.newLine); } } - output.forEach(function (val) { + output.forEach(function (val: any) { sys.write(val); - }) + }); return; function getParamType(option: CommandLineOption) { From 4ec9209a6a2e1230e922da460b72194acc4b8e7b Mon Sep 17 00:00:00 2001 From: Dafrok Date: Tue, 20 Sep 2016 10:13:46 +0800 Subject: [PATCH 3/3] Take a few changes. --- src/compiler/tsc.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 7cf8864d35785..b39c017384e16 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -667,7 +667,7 @@ namespace ts { } function printHelp() { - const output: any = []; + const output: string[] = []; // We want to align our "syntax" and "examples" commands to a certain margin. const syntaxLength = getDiagnosticText(Diagnostics.Syntax_Colon_0, "").length; @@ -765,9 +765,10 @@ namespace ts { output.push(sys.newLine); } } - output.forEach(function (val: any) { - sys.write(val); - }); + + for (const line of output) { + sys.write(line); + } return; function getParamType(option: CommandLineOption) {