Skip to content

Allow nested reverse mapped type printback #42485

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

Conversation

weswigham
Copy link
Member

When the reverse mapped type in question both isn't already being printed, and isn't the child type of a reverse mapping over a non-anonymous type (eg, Window or Number). This means that reverse mappings over object literal expression types should be printed back in full, rather than getting truncated.

To support this change, I've added caching into reverse mapped symbol type lookup (previously we'd redo the inference every time we asked for the type of the symbol), and introduced a simplification into the construction of reverse mapped symbols so we manufacture less type identities when doing deep reverse mappings (by recognizing that {[K in keyof T[K_1]]: Whatever<T[K_1]>]} is equivalent to {[K in keyof T]: Whatever<T>]} as far as reverse mapped symbol type inference is concerned). Without that, we'd manufacture new sets of type identities for every type mapped over for every level "down" we had to recur within a deeply-reverse mapped type.

Fixes #40003 in most cases.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 25, 2021
@weswigham
Copy link
Member Author

@typescript-bot perf test this
@typescript-bot user test this
@typescript-bot test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 25, 2021

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 84241ef. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 25, 2021

Heya @weswigham, I've started to run the perf test suite on this PR at 84241ef. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 25, 2021

Heya @weswigham, I've started to run the extended test suite on this PR at 84241ef. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 25, 2021

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at 84241ef. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..42485

Metric master 42485 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 346,467k (± 0.02%) 346,489k (± 0.02%) +23k (+ 0.01%) 346,325k 346,698k
Parse Time 1.98s (± 0.56%) 1.98s (± 0.69%) +0.01s (+ 0.35%) 1.95s 2.02s
Bind Time 0.82s (± 0.70%) 0.83s (± 0.72%) +0.00s (+ 0.36%) 0.81s 0.84s
Check Time 4.99s (± 0.67%) 5.00s (± 0.39%) +0.01s (+ 0.20%) 4.94s 5.04s
Emit Time 5.34s (± 0.63%) 5.35s (± 0.67%) +0.01s (+ 0.13%) 5.28s 5.42s
Total Time 13.14s (± 0.47%) 13.16s (± 0.40%) +0.02s (+ 0.15%) 13.03s 13.26s
Compiler-Unions - node (v10.16.3, x64)
Memory used 214,933k (± 0.05%) 215,071k (± 0.04%) +139k (+ 0.06%) 214,951k 215,212k
Parse Time 0.79s (± 0.66%) 0.79s (± 0.86%) +0.00s (+ 0.38%) 0.78s 0.81s
Bind Time 0.50s (± 0.73%) 0.49s (± 0.96%) -0.01s (- 1.21%) 0.48s 0.50s
Check Time 10.67s (± 0.51%) 10.73s (± 0.39%) +0.05s (+ 0.51%) 10.62s 10.83s
Emit Time 2.32s (± 0.86%) 2.33s (± 1.20%) +0.01s (+ 0.39%) 2.28s 2.38s
Total Time 14.28s (± 0.51%) 14.34s (± 0.41%) +0.06s (+ 0.40%) 14.17s 14.43s
Monaco - node (v10.16.3, x64)
Memory used 355,411k (± 0.02%) 355,381k (± 0.02%) -30k (- 0.01%) 355,148k 355,575k
Parse Time 1.59s (± 0.48%) 1.60s (± 0.64%) +0.01s (+ 0.31%) 1.58s 1.62s
Bind Time 0.72s (± 0.77%) 0.72s (± 0.65%) +0.00s (+ 0.28%) 0.71s 0.73s
Check Time 5.16s (± 0.35%) 5.18s (± 0.32%) +0.02s (+ 0.33%) 5.15s 5.22s
Emit Time 2.82s (± 0.77%) 2.83s (± 0.53%) +0.02s (+ 0.60%) 2.81s 2.88s
Total Time 10.29s (± 0.32%) 10.33s (± 0.36%) +0.04s (+ 0.42%) 10.28s 10.45s
TFS - node (v10.16.3, x64)
Memory used 308,190k (± 0.02%) 308,157k (± 0.01%) -33k (- 0.01%) 308,057k 308,235k
Parse Time 1.23s (± 0.61%) 1.23s (± 0.47%) 0.00s ( 0.00%) 1.22s 1.24s
Bind Time 0.68s (± 0.50%) 0.68s (± 0.82%) +0.00s (+ 0.15%) 0.67s 0.69s
Check Time 4.60s (± 0.38%) 4.59s (± 0.81%) -0.01s (- 0.13%) 4.51s 4.70s
Emit Time 2.95s (± 0.68%) 2.92s (± 1.05%) -0.03s (- 1.12%) 2.86s 2.98s
Total Time 9.46s (± 0.37%) 9.42s (± 0.55%) -0.04s (- 0.43%) 9.31s 9.50s
material-ui - node (v10.16.3, x64)
Memory used 496,354k (± 0.01%) 496,351k (± 0.02%) -3k (- 0.00%) 496,153k 496,543k
Parse Time 2.05s (± 0.78%) 2.05s (± 0.51%) -0.00s (- 0.19%) 2.02s 2.07s
Bind Time 0.65s (± 1.12%) 0.65s (± 1.67%) +0.00s (+ 0.62%) 0.64s 0.68s
Check Time 14.03s (± 0.10%) 14.07s (± 0.78%) +0.04s (+ 0.32%) 13.86s 14.41s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.73s (± 0.13%) 16.77s (± 0.68%) +0.05s (+ 0.29%) 16.57s 17.13s
Angular - node (v12.1.0, x64)
Memory used 324,045k (± 0.03%) 324,061k (± 0.02%) +16k (+ 0.00%) 323,895k 324,189k
Parse Time 1.98s (± 0.63%) 1.97s (± 0.72%) -0.01s (- 0.25%) 1.95s 2.01s
Bind Time 0.80s (± 0.74%) 0.80s (± 0.69%) -0.00s (- 0.25%) 0.79s 0.82s
Check Time 4.91s (± 1.04%) 4.91s (± 0.30%) +0.00s (+ 0.00%) 4.88s 4.94s
Emit Time 5.47s (± 0.68%) 5.48s (± 0.46%) +0.00s (+ 0.04%) 5.41s 5.52s
Total Time 13.17s (± 0.45%) 13.16s (± 0.37%) -0.01s (- 0.06%) 13.05s 13.25s
Compiler-Unions - node (v12.1.0, x64)
Memory used 200,231k (± 0.05%) 200,396k (± 0.05%) +165k (+ 0.08%) 200,152k 200,658k
Parse Time 0.77s (± 0.80%) 0.77s (± 0.58%) +0.00s (+ 0.13%) 0.76s 0.78s
Bind Time 0.49s (± 0.96%) 0.49s (± 0.75%) +0.00s (+ 0.41%) 0.49s 0.50s
Check Time 9.81s (± 0.74%) 9.85s (± 0.55%) +0.04s (+ 0.45%) 9.76s 10.00s
Emit Time 2.37s (± 2.13%) 2.36s (± 1.62%) -0.02s (- 0.63%) 2.29s 2.44s
Total Time 13.45s (± 0.59%) 13.47s (± 0.55%) +0.03s (+ 0.19%) 13.32s 13.66s
Monaco - node (v12.1.0, x64)
Memory used 337,523k (± 0.02%) 337,527k (± 0.01%) +4k (+ 0.00%) 337,462k 337,590k
Parse Time 1.58s (± 0.75%) 1.59s (± 0.78%) +0.01s (+ 0.32%) 1.57s 1.62s
Bind Time 0.70s (± 1.16%) 0.70s (± 0.79%) +0.00s (+ 0.29%) 0.69s 0.71s
Check Time 4.91s (± 0.49%) 4.93s (± 0.65%) +0.02s (+ 0.37%) 4.87s 5.01s
Emit Time 2.87s (± 0.70%) 2.88s (± 1.61%) +0.01s (+ 0.52%) 2.82s 3.05s
Total Time 10.06s (± 0.41%) 10.11s (± 0.56%) +0.05s (+ 0.45%) 9.98s 10.28s
TFS - node (v12.1.0, x64)
Memory used 292,361k (± 0.02%) 292,429k (± 0.03%) +68k (+ 0.02%) 292,281k 292,678k
Parse Time 1.25s (± 0.56%) 1.24s (± 0.73%) -0.01s (- 0.64%) 1.23s 1.27s
Bind Time 0.65s (± 0.95%) 0.65s (± 0.89%) +0.00s (+ 0.62%) 0.64s 0.67s
Check Time 4.50s (± 0.75%) 4.50s (± 0.57%) +0.01s (+ 0.18%) 4.45s 4.55s
Emit Time 2.92s (± 0.59%) 2.95s (± 0.58%) +0.03s (+ 1.06%) 2.92s 3.00s
Total Time 9.31s (± 0.53%) 9.35s (± 0.36%) +0.03s (+ 0.35%) 9.29s 9.41s
material-ui - node (v12.1.0, x64)
Memory used 473,403k (± 0.05%) 473,467k (± 0.04%) +64k (+ 0.01%) 472,652k 473,636k
Parse Time 2.06s (± 0.62%) 2.06s (± 0.34%) -0.00s (- 0.15%) 2.04s 2.07s
Bind Time 0.64s (± 0.78%) 0.63s (± 0.57%) -0.00s (- 0.16%) 0.63s 0.64s
Check Time 12.53s (± 0.83%) 12.50s (± 0.39%) -0.03s (- 0.20%) 12.43s 12.65s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.23s (± 0.70%) 15.20s (± 0.32%) -0.03s (- 0.19%) 15.13s 15.35s
Angular - node (v14.15.1, x64)
Memory used 322,699k (± 0.01%) 322,686k (± 0.01%) -13k (- 0.00%) 322,607k 322,784k
Parse Time 1.99s (± 0.58%) 1.99s (± 0.67%) +0.00s (+ 0.15%) 1.97s 2.03s
Bind Time 0.85s (± 0.70%) 0.85s (± 0.52%) -0.00s (- 0.23%) 0.85s 0.87s
Check Time 4.90s (± 0.38%) 4.89s (± 0.59%) -0.01s (- 0.14%) 4.82s 4.97s
Emit Time 5.57s (± 0.93%) 5.56s (± 0.60%) -0.00s (- 0.09%) 5.49s 5.62s
Total Time 13.31s (± 0.44%) 13.30s (± 0.46%) -0.01s (- 0.11%) 13.13s 13.39s
Compiler-Unions - node (v14.15.1, x64)
Memory used 201,125k (± 0.57%) 201,432k (± 0.56%) +307k (+ 0.15%) 199,732k 203,493k
Parse Time 0.81s (± 0.61%) 0.81s (± 0.73%) 0.00s ( 0.00%) 0.80s 0.82s
Bind Time 0.53s (± 0.69%) 0.53s (± 0.42%) +0.00s (+ 0.57%) 0.52s 0.53s
Check Time 9.82s (± 0.77%) 9.85s (± 0.63%) +0.04s (+ 0.36%) 9.74s 10.00s
Emit Time 2.33s (± 1.12%) 2.33s (± 0.95%) -0.01s (- 0.26%) 2.29s 2.37s
Total Time 13.49s (± 0.54%) 13.52s (± 0.50%) +0.03s (+ 0.21%) 13.38s 13.69s
Monaco - node (v14.15.1, x64)
Memory used 336,866k (± 0.01%) 336,864k (± 0.01%) -2k (- 0.00%) 336,793k 336,968k
Parse Time 1.64s (± 0.54%) 1.64s (± 0.62%) +0.00s (+ 0.24%) 1.62s 1.67s
Bind Time 0.73s (± 0.45%) 0.73s (± 0.64%) 0.00s ( 0.00%) 0.72s 0.74s
Check Time 4.85s (± 0.46%) 4.86s (± 0.45%) +0.01s (+ 0.27%) 4.82s 4.92s
Emit Time 2.93s (± 0.55%) 2.92s (± 0.48%) -0.01s (- 0.34%) 2.89s 2.95s
Total Time 10.15s (± 0.26%) 10.16s (± 0.32%) +0.01s (+ 0.07%) 10.11s 10.26s
TFS - node (v14.15.1, x64)
Memory used 291,593k (± 0.00%) 291,623k (± 0.00%) +30k (+ 0.01%) 291,588k 291,648k
Parse Time 1.29s (± 0.59%) 1.30s (± 1.59%) +0.01s (+ 0.77%) 1.28s 1.36s
Bind Time 0.69s (± 0.65%) 0.69s (± 0.81%) +0.00s (+ 0.00%) 0.68s 0.70s
Check Time 4.51s (± 0.37%) 4.50s (± 0.42%) -0.00s (- 0.09%) 4.46s 4.56s
Emit Time 3.04s (± 0.42%) 3.04s (± 0.57%) 0.00s ( 0.00%) 3.00s 3.08s
Total Time 9.53s (± 0.22%) 9.53s (± 0.35%) +0.00s (+ 0.04%) 9.44s 9.59s
material-ui - node (v14.15.1, x64)
Memory used 471,841k (± 0.04%) 471,919k (± 0.06%) +78k (+ 0.02%) 471,046k 472,313k
Parse Time 2.13s (± 0.63%) 2.13s (± 0.64%) +0.01s (+ 0.28%) 2.10s 2.16s
Bind Time 0.69s (± 0.50%) 0.69s (± 0.81%) +0.00s (+ 0.15%) 0.68s 0.70s
Check Time 12.75s (± 0.40%) 12.75s (± 0.83%) -0.00s (- 0.02%) 12.57s 13.00s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.57s (± 0.38%) 15.57s (± 0.65%) +0.01s (+ 0.04%) 15.41s 15.83s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-198-generic
Architecturex64
Available Memory16 GB
Available Memory10 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)
Benchmark Name Iterations
Current 42485 10
Baseline master 10

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

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.

  • I like the behaviour change,
  • agree with the index access simplification
  • have a question about the nested printback
  • don't feel qualified to OK the caching change (perf tests help here although I don't think we test mapped types at all on them)

@weswigham weswigham merged commit d1b4342 into microsoft:master Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

d.ts type is different than intellisense type
4 participants