No did-you-mean-to-call error on casts (#42626)

I chose to do the ad-hoc check rather than yet another tree walk.

1. It's faster to run and easier to read.
2. This error came from looking at real code. It happened twice, so I
think the best estimate for other uses that happened zero times is in
fact zero.
3. I couldn't think of other places to put the cast, given the
restrictions on `testedNode` just before the new code.
This commit is contained in:
Nathan Shively-Sanders
2021-02-12 09:36:55 -08:00
committed by GitHub
parent e72c015bca
commit f2bcb2101b
5 changed files with 83 additions and 1 deletions

View File

@@ -34546,8 +34546,11 @@ namespace ts {
: isPropertyAccessExpression(location) ? location.name
: isBinaryExpression(location) && isIdentifier(location.right) ? location.right
: undefined;
const isPropertyExpressionCast = isPropertyAccessExpression(location)
&& isParenthesizedExpression(location.expression)
&& isAssertionExpression(location.expression.expression);
if (!testedNode) {
if (!testedNode || isPropertyExpressionCast) {
return;
}