@@ -448,7 +448,7 @@ module ts {
448448 let declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined);
449449
450450 Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
451-
451+
452452 // first check if usage is lexically located after the declaration
453453 let isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
454454 if (!isUsedBeforeDeclaration) {
@@ -465,7 +465,7 @@ module ts {
465465
466466 if (variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement ||
467467 variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
468- // variable statement/for statement case,
468+ // variable statement/for statement case,
469469 // use site should not be inside variable declaration (initializer of declaration or binding element)
470470 isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
471471 }
@@ -9080,7 +9080,7 @@ module ts {
90809080 */
90819081 function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
90829082 Debug.assert(languageVersion < ScriptTarget.ES6);
9083-
9083+
90849084 // After we remove all types that are StringLike, we will know if there was a string constituent
90859085 // based on whether the remaining type is the same as the initial type.
90869086 let arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true);
@@ -11324,16 +11324,15 @@ module ts {
1132411324 }
1132511325 }
1132611326
11327- function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
11327+ function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile ): boolean {
1132811328 if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
1132911329 return true;
1133011330 }
1133111331
1133211332 if (typeParameters && typeParameters.length === 0) {
1133311333 let start = typeParameters.pos - "<".length;
11334- let sourceFile = getSourceFileOfNode(node);
11335- let end = skipTrivia(sourceFile.text, typeParameters.end) + ">".length;
11336- return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
11334+ let end = skipTrivia(file.text, typeParameters.end) + ">".length;
11335+ return grammarErrorAtPos(file, start, end - start, Diagnostics.Type_parameter_list_cannot_be_empty);
1133711336 }
1133811337 }
1133911338
@@ -11377,15 +11376,16 @@ module ts {
1137711376
1137811377 function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
1137911378 // Prevent cascading error by short-circuit
11380- return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node);
11379+ let file = getSourceFileOfNode(node);
11380+ return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
11381+ checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
1138111382 }
1138211383
11383- function checkGrammarArrowFunction(node: FunctionLikeDeclaration): boolean {
11384+ function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile ): boolean {
1138411385 if (node.kind === SyntaxKind.ArrowFunction) {
11385- var arrowFunction = <ArrowFunction>node;
11386- var sourceFile = getSourceFileOfNode(node);
11387- var startLine = getLineAndCharacterOfPosition(sourceFile, arrowFunction.equalsGreaterThanToken.pos).line;
11388- var endLine = getLineAndCharacterOfPosition(sourceFile, arrowFunction.equalsGreaterThanToken.end).line;
11386+ let arrowFunction = <ArrowFunction>node;
11387+ let startLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line;
11388+ let endLine = getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line;
1138911389 if (startLine !== endLine) {
1139011390 return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow);
1139111391 }
0 commit comments