TypeScript Version: [email protected]
Search Terms:
optional chaining receiver call parentheses
Code
const foo = { bar() { return this } };
console.assert(foo === (foo?.bar)());
Expected behavior:
foo should be propagated as the receiver to the foo.bar method call.
Actual behavior:
No receiver is propagated (due to the ternary breaking the receiver).
Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=4&pc=1#code/MYewdgzgLgBAZiEMC8MDeMBGBDATgCgEp0ZcBTKAV1zBigAsBLCGAXzYG4AoL0SEADZkAdNggQyuKPgRJk8mDMQB+YTlyEihDkA
Related Issues:
TypeScript Version: [email protected]
Search Terms:
optional chaining receiver call parentheses
Code
Expected behavior:
fooshould be propagated as the receiver to thefoo.barmethod call.Actual behavior:
No receiver is propagated (due to the ternary breaking the receiver).
Playground Link: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=4&pc=1#code/MYewdgzgLgBAZiEMC8MDeMBGBDATgCgEp0ZcBTKAV1zBigAsBLCGAXzYG4AoL0SEADZkAdNggQyuKPgRJk8mDMQB+YTlyEihDkA
Related Issues: