Skip to content

Commit d367c96

Browse files
CR feedback.
1 parent d3fbebf commit d367c96

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/compiler/utilities.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ module ts {
236236
};
237237
}
238238

239-
interface FileTextRange extends TextRange {
240-
sourceFile: SourceFile;
241-
}
242-
243239
/* @internal */
244240
export function getSpanOfTokenAtPosition(sourceFile: SourceFile, pos: number): TextSpan {
245241
var scanner = createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.text);
@@ -250,7 +246,7 @@ module ts {
250246
}
251247

252248
export function getErrorSpanForNode(sourceFile: SourceFile, node: Node): TextSpan {
253-
var errorNode: Node;
249+
var errorNode = node;
254250
switch (node.kind) {
255251
// This list is a work in progress. Add missing node kinds to improve their error
256252
// spans.
@@ -267,24 +263,12 @@ module ts {
267263
break;
268264
}
269265

270-
if (node.kind === SyntaxKind.FunctionExpression) {
271-
var functionExpression = <FunctionExpression>node;
272-
if (nodeIsMissing(functionExpression.name)) {
273-
// If it's an anonymous function expression, put the error on the first token.
274-
return getSpanOfTokenAtPosition(sourceFile, node.pos);
275-
}
276-
else {
277-
errorNode = functionExpression.name;
278-
}
266+
if (errorNode === undefined) {
267+
// If we don't have a better node, then just set the error on the first token of
268+
// construct.
269+
return getSpanOfTokenAtPosition(sourceFile, node.pos);
279270
}
280271

281-
// We now have the ideal error span, but it may be a node that is optional and absent
282-
// (e.g. the name of a function expression), in which case errorSpan will be undefined.
283-
// Alternatively, it might be required and missing (e.g. the name of a module), in which
284-
// case its pos will equal its end (length 0). In either of these cases, we should fall
285-
// back to the original node that the error was issued on.
286-
errorNode = nodeIsMissing(errorNode) ? node : errorNode;
287-
288272
var pos = nodeIsMissing(errorNode)
289273
? errorNode.pos
290274
: skipTrivia(sourceFile.text, errorNode.pos);

0 commit comments

Comments
 (0)