Skip to content

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

Merged
merged 3 commits into from
Feb 2, 2022

Conversation

Zzzen
Copy link
Contributor

@Zzzen Zzzen commented Dec 9, 2021

Fixes #47063

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 9, 2021
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Dec 9, 2021

I'm extremely worried about the perf implications of this...

Update: wrong!

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 9, 2021

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!

@typescript-bot
Copy link
Collaborator

@RyanCavanaugh
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..47085

Metric main 47085 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 354,953k (± 0.02%) 355,027k (± 0.02%) +73k (+ 0.02%) 354,816k 355,170k
Parse Time 1.95s (± 0.59%) 1.95s (± 0.49%) +0.00s (+ 0.26%) 1.94s 1.98s
Bind Time 0.85s (± 0.68%) 0.84s (± 0.71%) -0.01s (- 0.59%) 0.83s 0.86s
Check Time 5.51s (± 0.61%) 5.55s (± 0.42%) +0.03s (+ 0.56%) 5.48s 5.59s
Emit Time 5.93s (± 1.13%) 5.91s (± 0.65%) -0.01s (- 0.19%) 5.81s 6.02s
Total Time 14.24s (± 0.68%) 14.26s (± 0.39%) +0.02s (+ 0.13%) 14.11s 14.37s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,149k (± 0.04%) 204,151k (± 0.04%) +2k (+ 0.00%) 203,908k 204,257k
Parse Time 0.79s (± 1.09%) 0.79s (± 0.98%) -0.00s (- 0.13%) 0.78s 0.81s
Bind Time 0.52s (± 1.56%) 0.52s (± 1.11%) 0.00s ( 0.00%) 0.51s 0.53s
Check Time 7.87s (± 0.75%) 7.94s (± 0.92%) +0.07s (+ 0.86%) 7.81s 8.17s
Emit Time 2.46s (± 0.47%) 2.46s (± 0.74%) +0.00s (+ 0.12%) 2.42s 2.50s
Total Time 11.64s (± 0.50%) 11.71s (± 0.74%) +0.07s (+ 0.58%) 11.58s 11.99s
Monaco - node (v10.16.3, x64)
Memory used 342,521k (± 0.02%) 342,450k (± 0.01%) -71k (- 0.02%) 342,282k 342,509k
Parse Time 1.49s (± 0.40%) 1.48s (± 0.75%) -0.01s (- 0.54%) 1.45s 1.50s
Bind Time 0.75s (± 0.63%) 0.74s (± 0.49%) -0.01s (- 0.80%) 0.74s 0.75s
Check Time 5.55s (± 0.51%) 5.51s (± 0.73%) -0.03s (- 0.58%) 5.41s 5.58s
Emit Time 3.23s (± 1.11%) 3.22s (± 1.32%) -0.01s (- 0.34%) 3.14s 3.30s
Total Time 11.02s (± 0.45%) 10.95s (± 0.55%) -0.06s (- 0.56%) 10.84s 11.09s
TFS - node (v10.16.3, x64)
Memory used 305,551k (± 0.01%) 305,597k (± 0.03%) +46k (+ 0.02%) 305,439k 305,759k
Parse Time 1.20s (± 0.54%) 1.20s (± 0.61%) -0.00s (- 0.00%) 1.18s 1.21s
Bind Time 0.71s (± 0.78%) 0.71s (± 0.99%) +0.00s (+ 0.14%) 0.70s 0.73s
Check Time 5.03s (± 0.49%) 5.06s (± 0.62%) +0.04s (+ 0.70%) 5.00s 5.12s
Emit Time 3.38s (± 0.79%) 3.35s (± 0.88%) -0.03s (- 0.77%) 3.31s 3.45s
Total Time 10.32s (± 0.43%) 10.33s (± 0.39%) +0.01s (+ 0.11%) 10.25s 10.43s
material-ui - node (v10.16.3, x64)
Memory used 471,361k (± 0.02%) 471,358k (± 0.01%) -3k (- 0.00%) 471,234k 471,511k
Parse Time 1.78s (± 0.35%) 1.78s (± 0.41%) +0.00s (+ 0.06%) 1.77s 1.80s
Bind Time 0.66s (± 0.84%) 0.66s (± 0.98%) -0.00s (- 0.60%) 0.65s 0.67s
Check Time 14.28s (± 0.30%) 14.26s (± 0.57%) -0.02s (- 0.15%) 14.09s 14.46s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.73s (± 0.25%) 16.70s (± 0.54%) -0.03s (- 0.16%) 16.52s 16.92s
xstate - node (v10.16.3, x64)
Memory used 569,102k (± 0.02%) 569,286k (± 0.02%) +184k (+ 0.03%) 569,049k 569,554k
Parse Time 2.57s (± 0.38%) 2.56s (± 0.48%) -0.01s (- 0.27%) 2.54s 2.59s
Bind Time 1.01s (± 0.72%) 1.00s (± 0.73%) -0.01s (- 0.99%) 0.99s 1.02s
Check Time 1.50s (± 0.45%) 1.51s (± 0.67%) +0.01s (+ 0.60%) 1.48s 1.53s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.15s (± 0.32%) 5.13s (± 0.40%) -0.02s (- 0.35%) 5.10s 5.18s
Angular - node (v12.1.0, x64)
Memory used 332,787k (± 0.02%) 332,783k (± 0.03%) -5k (- 0.00%) 332,594k 333,008k
Parse Time 1.94s (± 0.57%) 1.95s (± 0.77%) +0.01s (+ 0.41%) 1.92s 1.99s
Bind Time 0.83s (± 0.81%) 0.82s (± 0.49%) -0.01s (- 0.97%) 0.81s 0.83s
Check Time 5.36s (± 0.44%) 5.35s (± 0.45%) -0.01s (- 0.13%) 5.30s 5.39s
Emit Time 6.20s (± 0.43%) 6.14s (± 0.60%) -0.06s (- 0.98%) 6.08s 6.23s
Total Time 14.33s (± 0.35%) 14.26s (± 0.25%) -0.07s (- 0.47%) 14.20s 14.35s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,573k (± 0.12%) 191,638k (± 0.08%) +65k (+ 0.03%) 191,096k 191,848k
Parse Time 0.78s (± 0.67%) 0.78s (± 0.71%) +0.00s (+ 0.13%) 0.77s 0.79s
Bind Time 0.54s (± 0.92%) 0.53s (± 0.90%) -0.01s (- 1.68%) 0.52s 0.54s
Check Time 7.38s (± 0.73%) 7.37s (± 0.55%) -0.01s (- 0.20%) 7.26s 7.45s
Emit Time 2.49s (± 0.93%) 2.49s (± 0.99%) -0.00s (- 0.08%) 2.41s 2.52s
Total Time 11.19s (± 0.65%) 11.16s (± 0.45%) -0.03s (- 0.22%) 11.06s 11.27s
Monaco - node (v12.1.0, x64)
Memory used 325,537k (± 0.02%) 325,642k (± 0.02%) +106k (+ 0.03%) 325,514k 325,782k
Parse Time 1.48s (± 0.56%) 1.47s (± 1.05%) -0.00s (- 0.27%) 1.44s 1.52s
Bind Time 0.73s (± 0.76%) 0.73s (± 0.79%) +0.01s (+ 0.69%) 0.72s 0.75s
Check Time 5.39s (± 0.35%) 5.38s (± 0.39%) -0.01s (- 0.17%) 5.34s 5.44s
Emit Time 3.24s (± 0.55%) 3.22s (± 0.54%) -0.03s (- 0.77%) 3.18s 3.26s
Total Time 10.84s (± 0.36%) 10.80s (± 0.35%) -0.04s (- 0.34%) 10.72s 10.91s
TFS - node (v12.1.0, x64)
Memory used 290,284k (± 0.03%) 290,265k (± 0.02%) -19k (- 0.01%) 290,120k 290,412k
Parse Time 1.22s (± 0.61%) 1.22s (± 0.77%) -0.00s (- 0.25%) 1.20s 1.24s
Bind Time 0.70s (± 0.74%) 0.69s (± 0.96%) -0.01s (- 1.57%) 0.68s 0.71s
Check Time 4.99s (± 0.51%) 4.96s (± 0.65%) -0.03s (- 0.60%) 4.91s 5.05s
Emit Time 3.42s (± 0.95%) 3.43s (± 1.45%) +0.01s (+ 0.18%) 3.31s 3.52s
Total Time 10.33s (± 0.49%) 10.29s (± 0.72%) -0.04s (- 0.38%) 10.15s 10.50s
material-ui - node (v12.1.0, x64)
Memory used 450,103k (± 0.01%) 450,117k (± 0.01%) +14k (+ 0.00%) 449,994k 450,281k
Parse Time 1.80s (± 0.37%) 1.79s (± 0.66%) -0.01s (- 0.61%) 1.77s 1.82s
Bind Time 0.65s (± 1.64%) 0.64s (± 0.92%) -0.00s (- 0.31%) 0.63s 0.66s
Check Time 12.90s (± 0.43%) 12.69s (± 0.42%) -0.21s (- 1.60%) 12.61s 12.82s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.35s (± 0.39%) 15.13s (± 0.31%) -0.22s (- 1.43%) 15.04s 15.24s
xstate - node (v12.1.0, x64)
Memory used 538,653k (± 1.43%) 535,176k (± 0.02%) -3,478k (- 0.65%) 535,022k 535,368k
Parse Time 2.50s (± 0.55%) 2.50s (± 0.37%) -0.00s (- 0.08%) 2.48s 2.52s
Bind Time 1.05s (± 0.90%) 1.05s (± 0.85%) -0.00s (- 0.10%) 1.03s 1.06s
Check Time 1.45s (± 0.85%) 1.44s (± 0.54%) -0.01s (- 0.62%) 1.43s 1.46s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.06s (± 0.53%) 5.05s (± 0.26%) -0.02s (- 0.34%) 5.03s 5.08s
Angular - node (v14.15.1, x64)
Memory used 331,258k (± 0.01%) 331,218k (± 0.01%) -40k (- 0.01%) 331,120k 331,277k
Parse Time 1.97s (± 0.57%) 1.95s (± 0.56%) -0.01s (- 0.71%) 1.93s 1.98s
Bind Time 0.87s (± 0.80%) 0.87s (± 0.69%) -0.01s (- 0.69%) 0.85s 0.88s
Check Time 5.44s (± 0.36%) 5.42s (± 0.72%) -0.02s (- 0.42%) 5.37s 5.53s
Emit Time 6.24s (± 1.03%) 6.24s (± 0.53%) -0.00s (- 0.08%) 6.17s 6.32s
Total Time 14.52s (± 0.61%) 14.47s (± 0.47%) -0.05s (- 0.34%) 14.37s 14.70s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,556k (± 0.61%) 191,443k (± 0.66%) -114k (- 0.06%) 189,099k 193,593k
Parse Time 0.81s (± 0.90%) 0.81s (± 0.58%) -0.00s (- 0.25%) 0.80s 0.82s
Bind Time 0.56s (± 0.80%) 0.55s (± 0.90%) -0.00s (- 0.54%) 0.55s 0.57s
Check Time 7.46s (± 0.58%) 7.42s (± 0.67%) -0.04s (- 0.60%) 7.31s 7.53s
Emit Time 2.50s (± 0.95%) 2.49s (± 1.03%) -0.01s (- 0.32%) 2.46s 2.56s
Total Time 11.33s (± 0.56%) 11.28s (± 0.57%) -0.06s (- 0.51%) 11.14s 11.40s
Monaco - node (v14.15.1, x64)
Memory used 324,376k (± 0.01%) 324,402k (± 0.01%) +26k (+ 0.01%) 324,370k 324,448k
Parse Time 1.52s (± 0.57%) 1.51s (± 0.54%) -0.01s (- 0.33%) 1.50s 1.53s
Bind Time 0.76s (± 0.44%) 0.76s (± 0.79%) -0.00s (- 0.66%) 0.74s 0.77s
Check Time 5.34s (± 0.54%) 5.33s (± 0.50%) -0.00s (- 0.09%) 5.26s 5.38s
Emit Time 3.28s (± 0.77%) 3.25s (± 0.50%) -0.02s (- 0.73%) 3.23s 3.30s
Total Time 10.89s (± 0.45%) 10.86s (± 0.37%) -0.03s (- 0.31%) 10.75s 10.93s
TFS - node (v14.15.1, x64)
Memory used 289,198k (± 0.01%) 289,199k (± 0.01%) +1k (+ 0.00%) 289,156k 289,245k
Parse Time 1.24s (± 0.50%) 1.23s (± 0.77%) -0.01s (- 0.48%) 1.21s 1.25s
Bind Time 0.74s (± 0.81%) 0.73s (± 0.45%) -0.01s (- 0.82%) 0.72s 0.74s
Check Time 4.98s (± 0.57%) 4.94s (± 0.51%) -0.04s (- 0.90%) 4.90s 5.00s
Emit Time 3.52s (± 1.08%) 3.48s (± 1.46%) -0.05s (- 1.30%) 3.29s 3.55s
Total Time 10.48s (± 0.46%) 10.38s (± 0.47%) -0.10s (- 0.96%) 10.23s 10.48s
material-ui - node (v14.15.1, x64)
Memory used 448,244k (± 0.06%) 448,362k (± 0.00%) +118k (+ 0.03%) 448,327k 448,409k
Parse Time 1.84s (± 0.55%) 1.83s (± 0.54%) -0.01s (- 0.33%) 1.82s 1.86s
Bind Time 0.68s (± 0.77%) 0.68s (± 0.50%) -0.00s (- 0.29%) 0.67s 0.68s
Check Time 12.87s (± 0.85%) 12.84s (± 0.51%) -0.03s (- 0.24%) 12.73s 12.99s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.38s (± 0.75%) 15.35s (± 0.40%) -0.04s (- 0.25%) 15.23s 15.49s
xstate - node (v14.15.1, x64)
Memory used 532,945k (± 0.00%) 532,909k (± 0.01%) -36k (- 0.01%) 532,846k 532,974k
Parse Time 2.57s (± 0.52%) 2.56s (± 0.45%) -0.00s (- 0.12%) 2.54s 2.58s
Bind Time 1.15s (± 0.87%) 1.15s (± 0.71%) 0.00s ( 0.00%) 1.13s 1.17s
Check Time 1.49s (± 0.39%) 1.50s (± 0.56%) +0.00s (+ 0.13%) 1.47s 1.51s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.29s (± 0.36%) 5.28s (± 0.35%) -0.00s (- 0.08%) 5.24s 5.32s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory9 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 47085 10
Baseline main 10

Developer Information:

Download Benchmark

@Zzzen
Copy link
Contributor Author

Zzzen commented Jan 4, 2022

And this happens to fix a symbol accessibility issue:

https://www.typescriptlang.org/play?#code/MYGwhgzhAEAqCmEAuBGAzNA3gKGn6AdgK4C20AvNAAwDcu+A9A9AApgBOYJ8S870AcmIkB0APYAzaAAciAIxABLYNG5IAFmIAm0CezFl4AD2lj2vHaEgx1kcf0UwiERQQDmM9ooBuYXoS54QQ1HAQA6ejxeZBQACmEALmgkAE9peElk9Ucw4QosnOEASixI6ABfbHKgA

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) {
    }
}

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

  1. One request to move code in checker.ts.
  2. One request to try normalising+extracting code in symbolDisplay.ts. (If it doesn't work, that's OK.)

@@ -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);
Copy link
Member

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)) {
Copy link
Member

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.

@sandersn
Copy link
Member

@RyanCavanaugh this change looks scary because it changes checkExpressionWorker but really all it does is check the type of this when it's inside typeof this, which didn't happen before. That's a tiny addition, so tiny that it's unlikely to occur in the perf tests.

@sandersn sandersn merged commit 880e2c0 into microsoft:main Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Quickinfo incorrectly reports "any" on typeof this
4 participants