Skip to content
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

fixed types for Object.values and Object.entries #58358

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

typeholes
Copy link

Fixes #26010

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 29, 2024
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 29, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests comparing main and refs/pull/58358/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 193,415k (± 0.92%) 194,619k (± 0.98%) ~ 192,137k 196,010k p=0.378 n=6
Parse Time 1.34s (± 1.38%) 1.35s (± 0.30%) ~ 1.35s 1.36s p=0.787 n=6
Bind Time 0.72s (± 0.57%) 0.72s ~ ~ ~ p=0.405 n=6
Check Time 9.58s (± 0.32%) 9.62s (± 0.30%) ~ 9.57s 9.65s p=0.077 n=6
Emit Time 2.61s (± 0.38%) 2.62s (± 0.57%) ~ 2.61s 2.65s p=0.209 n=6
Total Time 14.26s (± 0.29%) 14.32s (± 0.21%) +0.06s (+ 0.42%) 14.26s 14.34s p=0.024 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,172 945,416 +244 (+ 0.03%) ~ ~ p=0.001 n=6
Types 408,068 407,894 -174 (- 0.04%) ~ ~ p=0.001 n=6
Memory used 1,221,990k (± 0.00%) 1,222,117k (± 0.00%) +127k (+ 0.01%) 1,222,053k 1,222,171k p=0.008 n=6
Parse Time 8.23s (± 0.76%) 8.22s (± 0.51%) ~ 8.15s 8.28s p=0.936 n=6
Bind Time 2.24s (± 0.75%) 2.24s (± 0.59%) ~ 2.22s 2.25s p=0.933 n=6
Check Time 36.68s (± 0.30%) 36.63s (± 0.31%) ~ 36.48s 36.74s p=0.471 n=6
Emit Time 17.43s (± 0.34%) 17.44s (± 0.45%) ~ 17.34s 17.55s p=1.000 n=6
Total Time 64.57s (± 0.24%) 64.53s (± 0.32%) ~ 64.27s 64.80s p=0.689 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,955,870 1,955,915 +45 (+ 0.00%) ~ ~ p=0.001 n=6
Types 676,290 676,279 -11 (- 0.00%) ~ ~ p=0.001 n=6
Memory used 1,754,518k (± 0.00%) 1,754,514k (± 0.00%) ~ 1,754,420k 1,754,558k p=1.000 n=6
Parse Time 8.11s (± 0.40%) 8.09s (± 0.34%) ~ 8.04s 8.12s p=0.329 n=6
Bind Time 2.72s (± 0.49%) 2.73s (± 0.55%) ~ 2.72s 2.76s p=0.249 n=6
Check Time 67.07s (± 0.42%) 67.24s (± 0.37%) ~ 66.97s 67.56s p=0.297 n=6
Emit Time 0.16s (± 4.99%) 0.17s (± 6.19%) ~ 0.16s 0.18s p=0.595 n=6
Total Time 78.07s (± 0.38%) 78.23s (± 0.31%) ~ 77.98s 78.57s p=0.336 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,669 1,216,532 +863 (+ 0.07%) ~ ~ p=0.001 n=6
Types 257,620 257,489 -131 (- 0.05%) ~ ~ p=0.001 n=6
Memory used 2,323,692k (± 0.02%) 2,382,197k (± 6.00%) ~ 2,322,934k 2,674,296k p=0.936 n=6
Parse Time 7.62s (± 0.64%) 7.56s (± 0.60%) ~ 7.49s 7.63s p=0.054 n=6
Bind Time 2.75s (± 0.88%) 2.75s (± 0.38%) ~ 2.73s 2.76s p=0.293 n=6
Check Time 49.51s (± 0.64%) 49.00s (± 0.84%) -0.52s (- 1.04%) 48.42s 49.45s p=0.045 n=6
Emit Time 3.92s (± 0.50%) 3.84s (± 2.14%) -0.08s (- 2.04%) 3.72s 3.94s p=0.045 n=6
Total Time 63.80s (± 0.55%) 63.14s (± 0.67%) -0.66s (- 1.04%) 62.65s 63.65s p=0.020 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,215,669 1,216,532 +863 (+ 0.07%) ~ ~ p=0.001 n=6
Types 257,620 257,489 -131 (- 0.05%) ~ ~ p=0.001 n=6
Memory used 2,397,921k (± 0.01%) 2,398,508k (± 0.01%) +588k (+ 0.02%) 2,398,055k 2,398,833k p=0.020 n=6
Parse Time 6.34s (± 0.30%) 6.34s (± 0.19%) ~ 6.32s 6.35s p=1.000 n=6
Bind Time 2.01s (± 0.68%) 2.02s (± 0.94%) ~ 2.00s 2.04s p=0.218 n=6
Check Time 40.55s (± 0.18%) 40.06s (± 0.25%) -0.49s (- 1.22%) 39.95s 40.24s p=0.005 n=6
Emit Time 3.13s (± 0.89%) 3.13s (± 1.30%) ~ 3.10s 3.21s p=0.810 n=6
Total Time 52.03s (± 0.14%) 51.56s (± 0.18%) -0.47s (- 0.91%) 51.47s 51.73s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,176 256,241 +65 (+ 0.03%) ~ ~ p=0.001 n=6
Types 103,637 103,527 -110 (- 0.11%) ~ ~ p=0.001 n=6
Memory used 424,282k (± 0.01%) 424,309k (± 0.01%) ~ 424,264k 424,334k p=0.149 n=6
Parse Time 3.50s (± 0.72%) 3.49s (± 1.15%) ~ 3.42s 3.52s p=0.871 n=6
Bind Time 1.30s (± 1.26%) 1.30s (± 1.02%) ~ 1.28s 1.32s p=0.615 n=6
Check Time 18.29s (± 0.19%) 17.78s (± 0.39%) -0.51s (- 2.79%) 17.70s 17.86s p=0.005 n=6
Emit Time 1.36s (± 2.00%) 1.38s (± 2.22%) ~ 1.34s 1.42s p=0.468 n=6
Total Time 24.46s (± 0.17%) 23.95s (± 0.43%) -0.51s (- 2.09%) 23.79s 24.07s p=0.005 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,824 224,845 +21 (+ 0.01%) ~ ~ p=0.001 n=6
Types 93,390 93,394 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 369,312k (± 0.01%) 369,346k (± 0.01%) ~ 369,304k 369,388k p=0.066 n=6
Parse Time 3.67s (± 0.30%) 3.66s (± 0.61%) ~ 3.63s 3.68s p=0.365 n=6
Bind Time 1.93s (± 1.17%) 1.93s (± 0.76%) ~ 1.91s 1.95s p=0.935 n=6
Check Time 19.41s (± 0.32%) 19.40s (± 0.18%) ~ 19.36s 19.45s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 25.02s (± 0.26%) 24.99s (± 0.12%) ~ 24.95s 25.03s p=0.808 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,798,852 2,798,955 +103 (+ 0.00%) ~ ~ p=0.001 n=6
Types 950,749 950,678 -71 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 2,926,479k (± 0.00%) 2,926,449k (± 0.00%) ~ 2,926,343k 2,926,701k p=0.378 n=6
Parse Time 16.65s (± 0.41%) 16.68s (± 0.48%) ~ 16.53s 16.75s p=0.575 n=6
Bind Time 4.97s (± 0.45%) 5.05s (± 1.91%) +0.08s (+ 1.58%) 4.98s 5.24s p=0.015 n=6
Check Time 88.91s (± 0.49%) 88.92s (± 0.34%) ~ 88.40s 89.21s p=0.810 n=6
Emit Time 26.22s (± 9.58%) 26.95s (± 8.80%) ~ 23.83s 28.62s p=1.000 n=6
Total Time 136.75s (± 1.93%) 137.61s (± 1.67%) ~ 134.46s 139.26s p=0.873 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,853 265,957 +104 (+ 0.04%) ~ ~ p=0.001 n=6
Types 108,438 108,476 +38 (+ 0.04%) ~ ~ p=0.001 n=6
Memory used 410,404k (± 0.02%) 410,561k (± 0.02%) +157k (+ 0.04%) 410,448k 410,667k p=0.013 n=6
Parse Time 4.87s (± 0.49%) 4.88s (± 0.46%) ~ 4.85s 4.91s p=0.415 n=6
Bind Time 2.07s (± 1.04%) 2.07s (± 0.79%) ~ 2.04s 2.09s p=0.869 n=6
Check Time 21.12s (± 0.21%) 21.09s (± 0.24%) ~ 21.00s 21.13s p=0.170 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.07s (± 0.29%) 28.03s (± 0.21%) ~ 27.96s 28.09s p=0.630 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,981 524,002 +21 (+ 0.00%) ~ ~ p=0.001 n=6
Types 178,708 178,702 -6 (- 0.00%) ~ ~ p=0.001 n=6
Memory used 461,255k (± 0.01%) 461,299k (± 0.02%) ~ 461,223k 461,396k p=0.575 n=6
Parse Time 2.70s (± 0.68%) 2.69s (± 0.45%) ~ 2.67s 2.70s p=0.162 n=6
Bind Time 0.98s 0.98s (± 0.64%) ~ 0.97s 0.99s p=1.000 n=6
Check Time 15.50s (± 0.12%) 15.45s (± 0.77%) ~ 15.21s 15.53s p=0.627 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.18s (± 0.14%) 19.12s (± 0.62%) ~ 18.88s 19.19s p=0.294 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos comparing main and refs/pull/58358/merge:

Everything looks good!

@typeholes typeholes marked this pull request as ready for review April 30, 2024 14:58
@typeholes
Copy link
Author

Once #58372 🙂 lands the overload should probably be replaced by a simple union.

@typeholes
Copy link
Author

fixes #58376

@ehoogeveen-medweb
Copy link

ehoogeveen-medweb commented Apr 30, 2024

Does this also need some sort of handling for objects with symbol type keys? Properties with such keys won't be returned, but Object.values() and Object.entries() should still accept such objects.

@typeholes
Copy link
Author

Does this also need some sort of handling for objects with symbol type keys? Properties with such keys won't be returned, but Object.values() and Object.entries() should still accept such objects.

There is already an overload for values and entries, so they will be accepted.
for example, values(o: {}): any[]; Of course the any[] return type is not ideal, but I'm not sure anything else is workable for the fallback.

@ehoogeveen-medweb
Copy link

Thanks, I didn't look beyond the context of the diff :)

Locally I use something like this:

type KeyToString<K extends number | string | symbol> = K extends string ? K : K extends number ? `${K}` : never;

keys<K extends number | string | symbol, V>(o: Record<K, V>): KeyToString<K>[];
entries<K extends number | string | symbol, V>(o: Record<K, V>): [KeyToString<K>, V][];
values<K extends number | string | symbol, V>(o: Record<K, V>): V[];

but aside from being too complex for the standard library, that probably opens up a whole can of worms if applied to everything (works well for my code though!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
PR Backlog
  
Not started
Development

Successfully merging this pull request may close these issues.

Object.values and Object.entries return type any when passing an object defined as having number keys
4 participants