Skip to content

Commit d4403df

Browse files
committed
var -> let
1 parent ed1ff3d commit d4403df

8 files changed

Lines changed: 87 additions & 87 deletions

File tree

src/compiler/binder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ namespace ts {
474474
}
475475

476476
function hasExportDeclarations(node: ModuleDeclaration | SourceFile): boolean {
477-
var body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
477+
let body = node.kind === SyntaxKind.SourceFile ? node : (<ModuleDeclaration>node).body;
478478
if (body.kind === SyntaxKind.SourceFile || body.kind === SyntaxKind.ModuleBlock) {
479479
for (let stat of (<Block>body).statements) {
480480
if (stat.kind === SyntaxKind.ExportDeclaration || stat.kind === SyntaxKind.ExportAssignment) {
@@ -750,7 +750,7 @@ namespace ts {
750750
function bind(node: Node) {
751751
node.parent = parent;
752752

753-
var savedInStrictMode = inStrictMode;
753+
let savedInStrictMode = inStrictMode;
754754
if (!savedInStrictMode) {
755755
updateStrictMode(node);
756756
}

src/compiler/checker.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ namespace ts {
282282

283283
function getSymbolLinks(symbol: Symbol): SymbolLinks {
284284
if (symbol.flags & SymbolFlags.Transient) return <TransientSymbol>symbol;
285-
var id = getSymbolId(symbol);
285+
let id = getSymbolId(symbol);
286286
return symbolLinks[id] || (symbolLinks[id] = {});
287287
}
288288

@@ -630,7 +630,7 @@ namespace ts {
630630
}
631631

632632
function getTargetOfNamespaceImport(node: NamespaceImport): Symbol {
633-
var moduleSpecifier = (<ImportDeclaration>node.parent.parent).moduleSpecifier;
633+
let moduleSpecifier = (<ImportDeclaration>node.parent.parent).moduleSpecifier;
634634
return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier);
635635
}
636636

@@ -685,7 +685,7 @@ namespace ts {
685685

686686
function getPropertyOfVariable(symbol: Symbol, name: string): Symbol {
687687
if (symbol.flags & SymbolFlags.Variable) {
688-
var typeAnnotation = (<VariableDeclaration>symbol.valueDeclaration).type;
688+
let typeAnnotation = (<VariableDeclaration>symbol.valueDeclaration).type;
689689
if (typeAnnotation) {
690690
return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
691691
}
@@ -1305,7 +1305,7 @@ namespace ts {
13051305
// Mark the unexported alias as visible if its parent is visible
13061306
// because these kind of aliases can be used to name types in declaration file
13071307

1308-
var anyImportSyntax = getAnyImportSyntax(declaration);
1308+
let anyImportSyntax = getAnyImportSyntax(declaration);
13091309
if (anyImportSyntax &&
13101310
!(anyImportSyntax.flags & NodeFlags.Export) && // import clause without export
13111311
isDeclarationVisible(<Declaration>anyImportSyntax.parent)) {
@@ -2086,14 +2086,14 @@ namespace ts {
20862086
}
20872087

20882088
function collectLinkedAliases(node: Identifier): Node[] {
2089-
var exportSymbol: Symbol;
2089+
let exportSymbol: Symbol;
20902090
if (node.parent && node.parent.kind === SyntaxKind.ExportAssignment) {
20912091
exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, Diagnostics.Cannot_find_name_0, node);
20922092
}
20932093
else if (node.parent.kind === SyntaxKind.ExportSpecifier) {
20942094
exportSymbol = getTargetOfExportSpecifier(<ExportSpecifier>node.parent);
20952095
}
2096-
var result: Node[] = [];
2096+
let result: Node[] = [];
20972097
if (exportSymbol) {
20982098
buildVisibleNodeList(exportSymbol.declarations);
20992099
}
@@ -2102,16 +2102,16 @@ namespace ts {
21022102
function buildVisibleNodeList(declarations: Declaration[]) {
21032103
forEach(declarations, declaration => {
21042104
getNodeLinks(declaration).isVisible = true;
2105-
var resultNode = getAnyImportSyntax(declaration) || declaration;
2105+
let resultNode = getAnyImportSyntax(declaration) || declaration;
21062106
if (!contains(result, resultNode)) {
21072107
result.push(resultNode);
21082108
}
21092109

21102110
if (isInternalModuleImportEqualsDeclaration(declaration)) {
21112111
// Add the referenced top container visible
2112-
var internalModuleReference = <Identifier | QualifiedName>(<ImportEqualsDeclaration>declaration).moduleReference;
2113-
var firstIdentifier = getFirstIdentifier(internalModuleReference);
2114-
var importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
2112+
let internalModuleReference = <Identifier | QualifiedName>(<ImportEqualsDeclaration>declaration).moduleReference;
2113+
let firstIdentifier = getFirstIdentifier(internalModuleReference);
2114+
let importSymbol = resolveName(declaration, firstIdentifier.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace,
21152115
Diagnostics.Cannot_find_name_0, firstIdentifier);
21162116
buildVisibleNodeList(importSymbol.declarations);
21172117
}
@@ -2606,7 +2606,7 @@ namespace ts {
26062606

26072607
// The outer type parameters are those defined by enclosing generic classes, methods, or functions.
26082608
function getOuterTypeParametersOfClassOrInterface(symbol: Symbol): TypeParameter[] {
2609-
var declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);
2609+
let declaration = symbol.flags & SymbolFlags.Class ? symbol.valueDeclaration : getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration);
26102610
return appendOuterTypeParameters(undefined, declaration);
26112611
}
26122612

@@ -9908,7 +9908,7 @@ namespace ts {
99089908
// we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator.
99099909
switch (node.kind) {
99109910
case SyntaxKind.ClassDeclaration:
9911-
var constructor = getFirstConstructorWithBody(<ClassDeclaration>node);
9911+
let constructor = getFirstConstructorWithBody(<ClassDeclaration>node);
99129912
if (constructor) {
99139913
checkParameterTypeAnnotationsAsExpressions(constructor);
99149914
}
@@ -10159,7 +10159,7 @@ namespace ts {
1015910159
return;
1016010160
}
1016110161

10162-
var symbol = getSymbolOfNode(node);
10162+
let symbol = getSymbolOfNode(node);
1016310163
if (symbol.flags & SymbolFlags.FunctionScopedVariable) {
1016410164
let localDeclarationSymbol = resolveName(node, (<Identifier>node.name).text, SymbolFlags.Variable, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
1016510165
if (localDeclarationSymbol &&
@@ -11404,7 +11404,7 @@ namespace ts {
1140411404
}
1140511405

1140611406
// expression part in ElementAccess\PropertyAccess should be either identifier or dottedName
11407-
var current = expression;
11407+
let current = expression;
1140811408
while (current) {
1140911409
if (current.kind === SyntaxKind.Identifier) {
1141011410
break;
@@ -12614,7 +12614,7 @@ namespace ts {
1261412614
return false;
1261512615
}
1261612616

12617-
var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
12617+
let isValue = isAliasResolvedToValue(getSymbolOfNode(node));
1261812618
return isValue && node.moduleReference && !nodeIsMissing(node.moduleReference);
1261912619
}
1262012620

@@ -12698,7 +12698,7 @@ namespace ts {
1269812698
// here has no effect anyway as an identifier in a type name is not an expression.
1269912699
// var substitution = getExpressionNameSubstitution(<Identifier>node, getGeneratedNameForNode);
1270012700
// var text = substitution || (<Identifier>node).text;
12701-
var text = (<Identifier>node).text;
12701+
let text = (<Identifier>node).text;
1270212702
if (fallbackPath) {
1270312703
fallbackPath.push(text);
1270412704
}
@@ -12707,8 +12707,8 @@ namespace ts {
1270712707
}
1270812708
}
1270912709
else {
12710-
var left = serializeEntityName((<QualifiedName>node).left, fallbackPath);
12711-
var right = serializeEntityName((<QualifiedName>node).right, fallbackPath);
12710+
let left = serializeEntityName((<QualifiedName>node).left, fallbackPath);
12711+
let right = serializeEntityName((<QualifiedName>node).right, fallbackPath);
1271212712
if (!fallbackPath) {
1271312713
return left + "." + right;
1271412714
}
@@ -12748,7 +12748,7 @@ namespace ts {
1274812748
return "Symbol";
1274912749
}
1275012750
else if (type === unknownType) {
12751-
var fallbackPath: string[] = [];
12751+
let fallbackPath: string[] = [];
1275212752
serializeEntityName(node.typeName, fallbackPath);
1275312753
return fallbackPath;
1275412754
}
@@ -12843,22 +12843,22 @@ namespace ts {
1284312843
//
1284412844
// For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`.
1284512845
if (node) {
12846-
var valueDeclaration: FunctionLikeDeclaration;
12846+
let valueDeclaration: FunctionLikeDeclaration;
1284712847
if (node.kind === SyntaxKind.ClassDeclaration) {
1284812848
valueDeclaration = getFirstConstructorWithBody(<ClassDeclaration>node);
1284912849
}
1285012850
else if (isFunctionLike(node) && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
1285112851
valueDeclaration = <FunctionLikeDeclaration>node;
1285212852
}
1285312853
if (valueDeclaration) {
12854-
var result: (string | string[])[];
12855-
var parameters = valueDeclaration.parameters;
12856-
var parameterCount = parameters.length;
12854+
let result: (string | string[])[];
12855+
let parameters = valueDeclaration.parameters;
12856+
let parameterCount = parameters.length;
1285712857
if (parameterCount > 0) {
1285812858
result = new Array<string>(parameterCount);
12859-
for (var i = 0; i < parameterCount; i++) {
12859+
for (let i = 0; i < parameterCount; i++) {
1286012860
if (parameters[i].dotDotDotToken) {
12861-
var parameterType = parameters[i].type;
12861+
let parameterType = parameters[i].type;
1286212862
if (parameterType.kind === SyntaxKind.ArrayType) {
1286312863
parameterType = (<ArrayTypeNode>parameterType).elementType;
1286412864
}
@@ -12905,7 +12905,7 @@ namespace ts {
1290512905
}
1290612906

1290712907
function writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) {
12908-
var type = getTypeOfExpression(expr);
12908+
let type = getTypeOfExpression(expr);
1290912909
getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags);
1291012910
}
1291112911

src/compiler/commandLineParser.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ts {
77
/* @internal */
8-
export var optionDeclarations: CommandLineOption[] = [
8+
export let optionDeclarations: CommandLineOption[] = [
99
{
1010
name: "charset",
1111
type: "string",
@@ -207,11 +207,11 @@ namespace ts {
207207
];
208208

209209
export function parseCommandLine(commandLine: string[]): ParsedCommandLine {
210-
var options: CompilerOptions = {};
211-
var fileNames: string[] = [];
212-
var errors: Diagnostic[] = [];
213-
var shortOptionNames: Map<string> = {};
214-
var optionNameMap: Map<CommandLineOption> = {};
210+
let options: CompilerOptions = {};
211+
let fileNames: string[] = [];
212+
let errors: Diagnostic[] = [];
213+
let shortOptionNames: Map<string> = {};
214+
let optionNameMap: Map<CommandLineOption> = {};
215215

216216
forEach(optionDeclarations, option => {
217217
optionNameMap[option.name.toLowerCase()] = option;
@@ -227,9 +227,9 @@ namespace ts {
227227
};
228228

229229
function parseStrings(args: string[]) {
230-
var i = 0;
230+
let i = 0;
231231
while (i < args.length) {
232-
var s = args[i++];
232+
let s = args[i++];
233233
if (s.charCodeAt(0) === CharacterCodes.at) {
234234
parseResponseFile(s.slice(1));
235235
}
@@ -242,7 +242,7 @@ namespace ts {
242242
}
243243

244244
if (hasProperty(optionNameMap, s)) {
245-
var opt = optionNameMap[s];
245+
let opt = optionNameMap[s];
246246

247247
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
248248
if (!args[i] && opt.type !== "boolean") {
@@ -261,8 +261,8 @@ namespace ts {
261261
break;
262262
// If not a primitive, the possible types are specified in what is effectively a map of options.
263263
default:
264-
var map = <Map<number>>opt.type;
265-
var key = (args[i++] || "").toLowerCase();
264+
let map = <Map<number>>opt.type;
265+
let key = (args[i++] || "").toLowerCase();
266266
if (hasProperty(map, key)) {
267267
options[opt.name] = map[key];
268268
}
@@ -282,19 +282,19 @@ namespace ts {
282282
}
283283

284284
function parseResponseFile(fileName: string) {
285-
var text = sys.readFile(fileName);
285+
let text = sys.readFile(fileName);
286286

287287
if (!text) {
288288
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
289289
return;
290290
}
291291

292-
var args: string[] = [];
293-
var pos = 0;
292+
let args: string[] = [];
293+
let pos = 0;
294294
while (true) {
295295
while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++;
296296
if (pos >= text.length) break;
297-
var start = pos;
297+
let start = pos;
298298
if (text.charCodeAt(start) === CharacterCodes.doubleQuote) {
299299
pos++;
300300
while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++;
@@ -321,7 +321,7 @@ namespace ts {
321321
*/
322322
export function readConfigFile(fileName: string): { config?: any; error?: Diagnostic } {
323323
try {
324-
var text = sys.readFile(fileName);
324+
let text = sys.readFile(fileName);
325325
}
326326
catch (e) {
327327
return { error: createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -350,7 +350,7 @@ namespace ts {
350350
* file to. e.g. outDir
351351
*/
352352
export function parseConfigFile(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
353-
var errors: Diagnostic[] = [];
353+
let errors: Diagnostic[] = [];
354354

355355
return {
356356
options: getCompilerOptions(),
@@ -359,22 +359,22 @@ namespace ts {
359359
};
360360

361361
function getCompilerOptions(): CompilerOptions {
362-
var options: CompilerOptions = {};
363-
var optionNameMap: Map<CommandLineOption> = {};
362+
let options: CompilerOptions = {};
363+
let optionNameMap: Map<CommandLineOption> = {};
364364
forEach(optionDeclarations, option => {
365365
optionNameMap[option.name] = option;
366366
});
367-
var jsonOptions = json["compilerOptions"];
367+
let jsonOptions = json["compilerOptions"];
368368
if (jsonOptions) {
369-
for (var id in jsonOptions) {
369+
for (let id in jsonOptions) {
370370
if (hasProperty(optionNameMap, id)) {
371-
var opt = optionNameMap[id];
372-
var optType = opt.type;
373-
var value = jsonOptions[id];
374-
var expectedType = typeof optType === "string" ? optType : "string";
371+
let opt = optionNameMap[id];
372+
let optType = opt.type;
373+
let value = jsonOptions[id];
374+
let expectedType = typeof optType === "string" ? optType : "string";
375375
if (typeof value === expectedType) {
376376
if (typeof optType !== "string") {
377-
var key = value.toLowerCase();
377+
let key = value.toLowerCase();
378378
if (hasProperty(optType, key)) {
379379
value = optType[key];
380380
}
@@ -401,17 +401,17 @@ namespace ts {
401401
}
402402

403403
function getFileNames(): string[] {
404-
var fileNames: string[] = [];
404+
let fileNames: string[] = [];
405405
if (hasProperty(json, "files")) {
406406
if (json["files"] instanceof Array) {
407407
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
408408
}
409409
}
410410
else {
411-
var exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
412-
var sysFiles = host.readDirectory(basePath, ".ts", exclude);
413-
for (var i = 0; i < sysFiles.length; i++) {
414-
var name = sysFiles[i];
411+
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
412+
let sysFiles = host.readDirectory(basePath, ".ts", exclude);
413+
for (let i = 0; i < sysFiles.length; i++) {
414+
let name = sysFiles[i];
415415
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
416416
fileNames.push(name);
417417
}

0 commit comments

Comments
 (0)