* 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. * Skip parentheses
30 lines
530 B
TypeScript
30 lines
530 B
TypeScript
//// [truthinessCallExpressionCoercion3.ts]
|
|
// from #41640, based on an example in ant-design
|
|
interface I {
|
|
always(): void
|
|
}
|
|
|
|
function f(result: unknown) {
|
|
if ((result as I).always) {
|
|
return result
|
|
}
|
|
}
|
|
function g(result: unknown) {
|
|
if (((result as I)).always) {
|
|
return result
|
|
}
|
|
}
|
|
|
|
|
|
//// [truthinessCallExpressionCoercion3.js]
|
|
function f(result) {
|
|
if (result.always) {
|
|
return result;
|
|
}
|
|
}
|
|
function g(result) {
|
|
if (result.always) {
|
|
return result;
|
|
}
|
|
}
|