@@ -448,7 +448,7 @@ module ts {
448
448
let declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined);
449
449
450
450
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
451
-
451
+
452
452
// first check if usage is lexically located after the declaration
453
453
let isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation);
454
454
if (!isUsedBeforeDeclaration) {
@@ -465,7 +465,7 @@ module ts {
465
465
466
466
if (variableDeclaration.parent.parent.kind === SyntaxKind.VariableStatement ||
467
467
variableDeclaration.parent.parent.kind === SyntaxKind.ForStatement) {
468
- // variable statement/for statement case,
468
+ // variable statement/for statement case,
469
469
// use site should not be inside variable declaration (initializer of declaration or binding element)
470
470
isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container);
471
471
}
@@ -9080,7 +9080,7 @@ module ts {
9080
9080
*/
9081
9081
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
9082
9082
Debug.assert(languageVersion < ScriptTarget.ES6);
9083
-
9083
+
9084
9084
// After we remove all types that are StringLike, we will know if there was a string constituent
9085
9085
// based on whether the remaining type is the same as the initial type.
9086
9086
let arrayType = removeTypesFromUnionType(arrayOrStringType, TypeFlags.StringLike, /*isTypeOfKind*/ true, /*allowEmptyUnionResult*/ true);
@@ -11324,16 +11324,15 @@ module ts {
11324
11324
}
11325
11325
}
11326
11326
11327
- function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>): boolean {
11327
+ function checkGrammarTypeParameterList(node: FunctionLikeDeclaration, typeParameters: NodeArray<TypeParameterDeclaration>, file: SourceFile ): boolean {
11328
11328
if (checkGrammarForDisallowedTrailingComma(typeParameters)) {
11329
11329
return true;
11330
11330
}
11331
11331
11332
11332
if (typeParameters && typeParameters.length === 0) {
11333
11333
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);
11337
11336
}
11338
11337
}
11339
11338
@@ -11377,15 +11376,16 @@ module ts {
11377
11376
11378
11377
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
11379
11378
// 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);
11381
11382
}
11382
11383
11383
- function checkGrammarArrowFunction(node: FunctionLikeDeclaration): boolean {
11384
+ function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile ): boolean {
11384
11385
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;
11389
11389
if (startLine !== endLine) {
11390
11390
return grammarErrorOnNode(arrowFunction.equalsGreaterThanToken, Diagnostics.Line_terminator_not_permitted_before_arrow);
11391
11391
}
0 commit comments