var -> let

This commit is contained in:
Dan Quirk
2015-06-25 17:36:19 -07:00
parent ed1ff3d57d
commit d4403df35e
8 changed files with 87 additions and 87 deletions

View File

@@ -5,7 +5,7 @@
namespace ts {
/* @internal */
export var optionDeclarations: CommandLineOption[] = [
export let optionDeclarations: CommandLineOption[] = [
{
name: "charset",
type: "string",
@@ -207,11 +207,11 @@ namespace ts {
];
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
var options: CompilerOptions = {};
var fileNames: string[] = [];
var errors: Diagnostic[] = [];
var shortOptionNames: Map<string> = {};
var optionNameMap: Map<CommandLineOption> = {};
let options: CompilerOptions = {};
let fileNames: string[] = [];
let errors: Diagnostic[] = [];
let shortOptionNames: Map<string> = {};
let optionNameMap: Map<CommandLineOption> = {};
forEach(optionDeclarations, option => {
optionNameMap[option.name.toLowerCase()] = option;
@@ -227,9 +227,9 @@ namespace ts {
};
function parseStrings(args: string[]) {
var i = 0;
let i = 0;
while (i < args.length) {
var s = args[i++];
let s = args[i++];
if (s.charCodeAt(0) === CharacterCodes.at) {
parseResponseFile(s.slice(1));
}
@@ -242,7 +242,7 @@ namespace ts {
}
if (hasProperty(optionNameMap, s)) {
var opt = optionNameMap[s];
let opt = optionNameMap[s];
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
if (!args[i] && opt.type !== "boolean") {
@@ -261,8 +261,8 @@ namespace ts {
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:
var map = <Map<number>>opt.type;
var key = (args[i++] || "").toLowerCase();
let map = <Map<number>>opt.type;
let key = (args[i++] || "").toLowerCase();
if (hasProperty(map, key)) {
options[opt.name] = map[key];
}
@@ -282,19 +282,19 @@ namespace ts {
}
function parseResponseFile(fileName: string) {
var text = sys.readFile(fileName);
let text = sys.readFile(fileName);
if (!text) {
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
return;
}
var args: string[] = [];
var pos = 0;
let args: string[] = [];
let pos = 0;
while (true) {
while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++;
if (pos >= text.length) break;
var start = pos;
let start = pos;
if (text.charCodeAt(start) === CharacterCodes.doubleQuote) {
pos++;
while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++;
@@ -321,7 +321,7 @@ namespace ts {
*/
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
try {
var text = sys.readFile(fileName);
let text = sys.readFile(fileName);
}
catch (e) {
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -350,7 +350,7 @@ namespace ts {
* file to. e.g. outDir
*/
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
var errors: Diagnostic[] = [];
let errors: Diagnostic[] = [];
return {
options: getCompilerOptions(),
@@ -359,22 +359,22 @@ namespace ts {
};
function getCompilerOptions(): CompilerOptions {
var options: CompilerOptions = {};
var optionNameMap: Map<CommandLineOption> = {};
let options: CompilerOptions = {};
let optionNameMap: Map<CommandLineOption> = {};
forEach(optionDeclarations, option => {
optionNameMap[option.name] = option;
});
var jsonOptions = json["compilerOptions"];
let jsonOptions = json["compilerOptions"];
if (jsonOptions) {
for (var id in jsonOptions) {
for (let id in jsonOptions) {
if (hasProperty(optionNameMap, id)) {
var opt = optionNameMap[id];
var optType = opt.type;
var value = jsonOptions[id];
var expectedType = typeof optType === "string" ? optType : "string";
let opt = optionNameMap[id];
let optType = opt.type;
let value = jsonOptions[id];
let expectedType = typeof optType === "string" ? optType : "string";
if (typeof value === expectedType) {
if (typeof optType !== "string") {
var key = value.toLowerCase();
let key = value.toLowerCase();
if (hasProperty(optType, key)) {
value = optType[key];
}
@@ -401,17 +401,17 @@ namespace ts {
}
function getFileNames(): string[] {
var fileNames: string[] = [];
let fileNames: string[] = [];
if (hasProperty(json, "files")) {
if (json["files"] instanceof Array) {
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
}
}
else {
var exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
var sysFiles = host.readDirectory(basePath, ".ts", exclude);
for (var i = 0; i < sysFiles.length; i++) {
var name = sysFiles[i];
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
let sysFiles = host.readDirectory(basePath, ".ts", exclude);
for (let i = 0; i < sysFiles.length; i++) {
let name = sysFiles[i];
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
fileNames.push(name);
}