-
Notifications
You must be signed in to change notification settings - Fork 13k
Make goto-definition go to a signature declaration if possible #10593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6f2567e
to
4514f8f
Compare
return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (<CallExpression>node.parent).expression === node; | ||
} | ||
|
||
function getCallOrNewExpressionWorker(node: Node, kind: SyntaxKind): Node | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the type of kind
to SyntaxKind.CallExpression | SyntaxKind.NewExpression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need to do a new LKG before using enums-as-unions.
For the record, calls and If it's not too hard, it'd be ideal to keep the behavior consistent between them. |
Can you also add a test for going to definition on a call where overload resolution failed? declare function doStuff(n: number): number;
declare function doStuff(s: string): string;
/**/doStuff(true); Ideally, the language service should still jump to one of the overloads. |
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined { | ||
const target = climbPastManyPropertyAccesses(node); | ||
const callLike = target.parent; | ||
return isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put callLike
first to bail early
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined { | ||
const target = climbPastManyPropertyAccesses(node); | ||
const callLike = target.parent; | ||
return callLike && isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you are checking callLike
twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First one is checking whether it exists. Last one is returning it from the function.
Other than the comments, 👍 |
Fixes #9269 and #10074