Description
Hopefully this is not a duplicate (couldn't find anything). Out of all the "less desirable" VS (and VS code as well) plugin behaviors I've found this to be the number one most disturbing:
TypeScript Version:
1.8.7 (VS 2015 Community, Update 1)
And after fixing the return type (only changed PromiseX.start<void>
to PromiseX.start<any>
):
Reduced test case
function func(f: () => number) {
}
func(() => {
let x = "HI"; // <-- Whole line highlighted in red
return x; // <-- Whole line highlighted in red
});
For comparison, when function
is used instead, only the keyword "function" is highlighted:
function func(f: () => number) {
}
func(function() { // <-- only the "function" keyword is highlighted in red
let x = "HI";
return x;
});
Suggestion
No need to highlight the whole function body in this case. Highlighting only the arrow (i.e. =>
) could also work (I tried to find a solution that would work with all variations of the arrow notation, e.g. including reduced notation like val => val * 2
). This would be significantly less distracting and wouldn't mask other errors within the function scope.
On a more personal note, I would be super-thankful if this would be fixed! This happens very frequently when using callback or promise heavy code (I mean sometimes up to hundreds of times per day).