-
Notifications
You must be signed in to change notification settings - Fork 12.9k
support quickinfo and go-to-definition on typeof this
#47085
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
I'm extremely worried about the perf implications of this... Update: wrong! @typescript-bot perf test this |
Heya @RyanCavanaugh, I've started to run the perf test suite on this PR at 134d561. You can monitor the build here. Update: The results are in! |
@RyanCavanaugh Here they are:Comparison Report - main..47085
System
Hosts
Scenarios
Developer Information: |
And this happens to fix a symbol accessibility issue: class Test13 {
num = 0;
// Parameter 'num' of public method from exported class has or is using private name 'this'.
test1(num: typeof this.num = this.num) {
}
} |
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.
Looks good.
- One request to move code in checker.ts.
- One request to try normalising+extracting code in symbolDisplay.ts. (If it doesn't work, that's OK.)
src/compiler/checker.ts
Outdated
@@ -34018,7 +34018,7 @@ namespace ts { | |||
} | |||
switch (kind) { | |||
case SyntaxKind.Identifier: | |||
return checkIdentifier(node as Identifier, checkMode); | |||
return isThisInTypeQuery(node) ? checkThisExpression(node) : checkIdentifier(node as Identifier, checkMode); |
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.
fairly minor style request: move this check into the top of checkIdentifier
. It's only called from here, and it keeps checkExpressionWorker as simple as possible.
(Looking at the rest of checkExpressionWorker, the only exception I see is BigIntLiteral, which just has the inline source of what should be checkBigIntLiteral.)
@@ -41,7 +41,7 @@ namespace ts.SymbolDisplay { | |||
if (typeChecker.isArgumentsSymbol(symbol)) { | |||
return ScriptElementKind.localVariableElement; | |||
} | |||
if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) { | |||
if (location.kind === SyntaxKind.ThisKeyword && isExpression(location) || isThisInTypeQuery(location)) { |
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.
This is probably out of scope for this review, but it would be nice for these two checks to use the same code (not isExpression
vs isExpressionContext
), and then be extracted to a function.
@RyanCavanaugh this change looks scary because it changes checkExpressionWorker but really all it does is check the type of |
Fixes #47063