mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-08 02:46:15 -05:00
Skip parens and non-null assertions when looking for this-context (#23097)
* Skip parens and ! for getting this-context of call * Add test and improve code a bit * Use skipOuterExpressions instead
This commit is contained in:
committed by
GitHub
parent
a2c11bb7a0
commit
11eabc0946
@@ -17269,12 +17269,9 @@ namespace ts {
|
||||
*/
|
||||
function getThisArgumentOfCall(node: CallLikeExpression): LeftHandSideExpression {
|
||||
if (node.kind === SyntaxKind.CallExpression) {
|
||||
const callee = node.expression;
|
||||
if (callee.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
return (callee as PropertyAccessExpression).expression;
|
||||
}
|
||||
else if (callee.kind === SyntaxKind.ElementAccessExpression) {
|
||||
return (callee as ElementAccessExpression).expression;
|
||||
const callee = skipOuterExpressions(node.expression);
|
||||
if (callee.kind === SyntaxKind.PropertyAccessExpression || callee.kind === SyntaxKind.ElementAccessExpression) {
|
||||
return (callee as PropertyAccessExpression | ElementAccessExpression).expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2022,7 +2022,7 @@ namespace ts {
|
||||
export function skipParentheses(node: Node): Node;
|
||||
export function skipParentheses(node: Node): Node {
|
||||
while (node.kind === SyntaxKind.ParenthesizedExpression) {
|
||||
node = (<ParenthesizedExpression>node).expression;
|
||||
node = (node as ParenthesizedExpression).expression;
|
||||
}
|
||||
|
||||
return node;
|
||||
|
||||
Reference in New Issue
Block a user