mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Component commits: 214ef0c750 No did-you-mean-to-call error on casts 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. 1d347785de Merge branch 'master' into no-did-you-mean-to-call-error-on-casts b3be79ad0f Skip parentheses 2a288127e9 Merge branch 'master' into no-did-you-mean-to-call-error-on-casts Co-authored-by: Nathan Shively-Sanders <nathansa@microsoft.com>
This commit is contained in:
parent
7f64b3a82c
commit
16f2556473
@ -34543,9 +34543,7 @@ namespace ts {
|
||||
: isBinaryExpression(location) && isIdentifier(location.right) ? location.right
|
||||
: undefined;
|
||||
const isPropertyExpressionCast = isPropertyAccessExpression(location)
|
||||
&& isParenthesizedExpression(location.expression)
|
||||
&& isAssertionExpression(location.expression.expression);
|
||||
|
||||
&& isAssertionExpression(skipParentheses(location.expression));
|
||||
if (!testedNode || isPropertyExpressionCast) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -9,6 +9,11 @@ function f(result: unknown) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
function g(result: unknown) {
|
||||
if (((result as I)).always) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [truthinessCallExpressionCoercion3.js]
|
||||
@ -17,3 +22,8 @@ function f(result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
function g(result) {
|
||||
if (result.always) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,4 +21,18 @@ function f(result: unknown) {
|
||||
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 5, 11))
|
||||
}
|
||||
}
|
||||
function g(result: unknown) {
|
||||
>g : Symbol(g, Decl(truthinessCallExpressionCoercion3.ts, 9, 1))
|
||||
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
|
||||
|
||||
if (((result as I)).always) {
|
||||
>((result as I)).always : Symbol(I.always, Decl(truthinessCallExpressionCoercion3.ts, 1, 13))
|
||||
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
|
||||
>I : Symbol(I, Decl(truthinessCallExpressionCoercion3.ts, 0, 0))
|
||||
>always : Symbol(I.always, Decl(truthinessCallExpressionCoercion3.ts, 1, 13))
|
||||
|
||||
return result
|
||||
>result : Symbol(result, Decl(truthinessCallExpressionCoercion3.ts, 10, 11))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,4 +20,20 @@ function f(result: unknown) {
|
||||
>result : unknown
|
||||
}
|
||||
}
|
||||
function g(result: unknown) {
|
||||
>g : (result: unknown) => unknown
|
||||
>result : unknown
|
||||
|
||||
if (((result as I)).always) {
|
||||
>((result as I)).always : () => void
|
||||
>((result as I)) : I
|
||||
>(result as I) : I
|
||||
>result as I : I
|
||||
>result : unknown
|
||||
>always : () => void
|
||||
|
||||
return result
|
||||
>result : unknown
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,3 +11,8 @@ function f(result: unknown) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
function g(result: unknown) {
|
||||
if (((result as I)).always) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user