@@ -850,8 +850,7 @@ module ts {
850850
851851 function findConstructorDeclaration(node: ClassDeclaration): ConstructorDeclaration {
852852 var members = node.members;
853- for (var i = 0; i < members.length; i++) {
854- var member = members[i];
853+ for (let member of members) {
855854 if (member.kind === SyntaxKind.Constructor && nodeIsPresent((<ConstructorDeclaration>member).body)) {
856855 return <ConstructorDeclaration>member;
857856 }
@@ -1549,8 +1548,7 @@ module ts {
15491548 writePunctuation(writer, SyntaxKind.SemicolonToken);
15501549 writer.writeLine();
15511550 }
1552- for (var i = 0; i < resolved.properties.length; i++) {
1553- var p = resolved.properties[i];
1551+ for (let p of resolved.properties) {
15541552 var t = getTypeOfSymbol(p);
15551553 if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) {
15561554 var signatures = getSignaturesOfType(t, SignatureKind.Call);
@@ -2402,25 +2400,22 @@ module ts {
24022400
24032401 function createSymbolTable(symbols: Symbol[]): SymbolTable {
24042402 var result: SymbolTable = {};
2405- for (var i = 0; i < symbols.length; i++) {
2406- var symbol = symbols[i];
2403+ for (let symbol of symbols) {
24072404 result[symbol.name] = symbol;
24082405 }
24092406 return result;
24102407 }
24112408
24122409 function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper): SymbolTable {
24132410 var result: SymbolTable = {};
2414- for (var i = 0; i < symbols.length; i++) {
2415- var symbol = symbols[i];
2411+ for (let symbol of symbols) {
24162412 result[symbol.name] = instantiateSymbol(symbol, mapper);
24172413 }
24182414 return result;
24192415 }
24202416
24212417 function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) {
2422- for (var i = 0; i < baseSymbols.length; i++) {
2423- var s = baseSymbols[i];
2418+ for (let s of baseSymbols) {
24242419 if (!hasProperty(symbols, s.name)) {
24252420 symbols[s.name] = s;
24262421 }
@@ -2728,8 +2723,7 @@ module ts {
27282723 }
27292724 var propTypes: Type[] = [];
27302725 var declarations: Declaration[] = [];
2731- for (var i = 0; i < props.length; i++) {
2732- var prop = props[i];
2726+ for (let prop of props) {
27332727 if (prop.declarations) {
27342728 declarations.push.apply(declarations, prop.declarations);
27352729 }
@@ -3181,8 +3175,7 @@ module ts {
31813175
31823176 function getTypeDeclaration(symbol: Symbol): Declaration {
31833177 var declarations = symbol.declarations;
3184- for (var i = 0; i < declarations.length; i++) {
3185- var declaration = declarations[i];
3178+ for (let declaration of declarations) {
31863179 switch (declaration.kind) {
31873180 case SyntaxKind.ClassDeclaration:
31883181 case SyntaxKind.InterfaceDeclaration:
@@ -3982,8 +3975,7 @@ module ts {
39823975 var result = Ternary.True;
39833976 var properties = getPropertiesOfObjectType(target);
39843977 var requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral);
3985- for (var i = 0; i < properties.length; i++) {
3986- var targetProp = properties[i];
3978+ for (let targetProp of properties) {
39873979 var sourceProp = getPropertyOfType(source, targetProp.name);
39883980 if (sourceProp !== targetProp) {
39893981 if (!sourceProp) {
@@ -4091,8 +4083,7 @@ module ts {
40914083 var targetSignatures = getSignaturesOfType(target, kind);
40924084 var result = Ternary.True;
40934085 var saveErrorInfo = errorInfo;
4094- outer: for (var i = 0; i < targetSignatures.length; i++) {
4095- var t = targetSignatures[i];
4086+ outer: for (let t of targetSignatures) {
40964087 if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) {
40974088 var localErrors = reportErrors;
40984089 for (var j = 0; j < sourceSignatures.length; j++) {
@@ -4608,8 +4599,7 @@ module ts {
46084599 var typeParameterCount = 0;
46094600 var typeParameter: TypeParameter;
46104601 // First infer to each type in union that isn't a type parameter
4611- for (var i = 0; i < targetTypes.length; i++) {
4612- var t = targetTypes[i];
4602+ for (let t of targetTypes) {
46134603 if (t.flags & TypeFlags.TypeParameter && contains(context.typeParameters, t)) {
46144604 typeParameter = <TypeParameter>t;
46154605 typeParameterCount++;
@@ -4656,8 +4646,7 @@ module ts {
46564646
46574647 function inferFromProperties(source: Type, target: Type) {
46584648 var properties = getPropertiesOfObjectType(target);
4659- for (var i = 0; i < properties.length; i++) {
4660- var targetProp = properties[i];
4649+ for (let targetProp of properties) {
46614650 var sourceProp = getPropertyOfObjectType(source, targetProp.name);
46624651 if (sourceProp) {
46634652 inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
@@ -5789,8 +5778,7 @@ module ts {
57895778 var contextualType = getContextualType(node);
57905779 var typeFlags: TypeFlags;
57915780
5792- for (var i = 0; i < node.properties.length; i++) {
5793- var memberDecl = node.properties[i];
5781+ for (let memberDecl of node.properties) {
57945782 var member = memberDecl.symbol;
57955783 if (memberDecl.kind === SyntaxKind.PropertyAssignment ||
57965784 memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment ||
@@ -6167,8 +6155,7 @@ module ts {
61676155 var specializedIndex: number = -1;
61686156 var spliceIndex: number;
61696157 Debug.assert(!result.length);
6170- for (var i = 0; i < signatures.length; i++) {
6171- var signature = signatures[i];
6158+ for (let signature of signatures) {
61726159 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
61736160 var parent = signature.declaration && signature.declaration.parent;
61746161 if (!lastSymbol || symbol === lastSymbol) {
@@ -7272,8 +7259,7 @@ module ts {
72727259
72737260 function checkObjectLiteralAssignment(node: ObjectLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
72747261 var properties = node.properties;
7275- for (var i = 0; i < properties.length; i++) {
7276- var p = properties[i];
7262+ for (let p of properties) {
72777263 if (p.kind === SyntaxKind.PropertyAssignment || p.kind === SyntaxKind.ShorthandPropertyAssignment) {
72787264 // TODO(andersh): Computed property support
72797265 var name = <Identifier>(<PropertyAssignment>p).name;
@@ -8097,8 +8083,7 @@ module ts {
80978083 signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode));
80988084 }
80998085
8100- for (var i = 0; i < signaturesToCheck.length; i++) {
8101- var otherSignature = signaturesToCheck[i];
8086+ for (let otherSignature of signaturesToCheck) {
81028087 if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) {
81038088 return;
81048089 }
@@ -9281,8 +9266,7 @@ module ts {
92819266
92829267 if (type.flags & TypeFlags.Class && type.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) {
92839268 var classDeclaration = <ClassDeclaration>type.symbol.valueDeclaration;
9284- for (var i = 0; i < classDeclaration.members.length; i++) {
9285- var member = classDeclaration.members[i];
9269+ for (let member of classDeclaration.members) {
92869270 // Only process instance properties with computed names here.
92879271 // Static properties cannot be in conflict with indexers,
92889272 // and properties with literal names were already checked.
@@ -9371,12 +9355,12 @@ module ts {
93719355 // Check each type parameter and check that list has no duplicate type parameter declarations
93729356 function checkTypeParameters(typeParameterDeclarations: TypeParameterDeclaration[]) {
93739357 if (typeParameterDeclarations) {
9374- for (var i = 0; i < typeParameterDeclarations.length; i++) {
9358+ for (let i = 0, n = typeParameterDeclarations.length; i < n ; i++) {
93759359 var node = typeParameterDeclarations[i];
93769360 checkTypeParameter(node);
93779361
93789362 if (produceDiagnostics) {
9379- for (var j = 0; j < i; j++) {
9363+ for (let j = 0; j < i; j++) {
93809364 if (typeParameterDeclarations[j].symbol === node.symbol) {
93819365 error(node.name, Diagnostics.Duplicate_identifier_0, declarationNameToString(node.name));
93829366 }
@@ -9855,8 +9839,7 @@ module ts {
98559839
98569840 function getFirstNonAmbientClassOrFunctionDeclaration(symbol: Symbol): Declaration {
98579841 var declarations = symbol.declarations;
9858- for (var i = 0; i < declarations.length; i++) {
9859- var declaration = declarations[i];
9842+ for (let declaration of declarations) {
98609843 if ((declaration.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.FunctionDeclaration && nodeIsPresent((<FunctionLikeDeclaration>declaration).body))) && !isInAmbientContext(declaration)) {
98619844 return declaration;
98629845 }
0 commit comments