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

Infer from type arguments of the same alias in inferFromObjectTypes #57895

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

Conversation

Andarist
Copy link
Contributor

I noticed that inferFromObjectTypes already does this "shortcircuit" between type references but it doesn't do the same in this other case. Both are handled by inferFromTypes. The logic related to type references in inferFromObjectTypes is almost the same as the one in inferFromTypes (the latter has one extra condition) - including exactly the same inline comment. Something tells me that, at some point, it was copy-pasted from the other place.

I verified that this added branch is sometimes hit by the existing test suite (not a lot though). I wonder if the perf tests would show anything particularly interesting here (I kinda doubt it though - based on the mentioned infrequest hits here).

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 21, 2024
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@@ -26187,6 +26187,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function inferFromObjectTypes(source: Type, target: Type) {
if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is literally copied-over from inferFromTypes

@jakebailey
Copy link
Member

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

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 21, 2024

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

Command Status Results
test top200 ✅ 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/57895/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
Angular - node (v18.15.0, x64)
Memory used 295,526k (± 0.00%) 295,531k (± 0.00%) ~ 295,521k 295,551k p=0.575 n=6
Parse Time 2.65s (± 0.46%) 2.65s (± 0.00%) ~ 2.65s 2.65s p=0.121 n=6
Bind Time 0.83s (± 1.08%) 0.82s (± 0.50%) ~ 0.82s 0.83s p=0.086 n=6
Check Time 8.19s (± 0.33%) 8.20s (± 0.20%) ~ 8.19s 8.23s p=0.255 n=6
Emit Time 7.05s (± 0.40%) 7.02s (± 0.18%) ~ 7.00s 7.04s p=0.060 n=6
Total Time 18.73s (± 0.17%) 18.70s (± 0.09%) ~ 18.68s 18.72s p=0.050 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,654k (± 1.01%) 193,716k (± 0.98%) ~ 191,909k 195,575k p=0.575 n=6
Parse Time 1.36s (± 1.11%) 1.36s (± 1.14%) ~ 1.35s 1.38s p=1.000 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.57%) ~ 0.72s 0.73s p=0.405 n=6
Check Time 9.49s (± 0.96%) 9.52s (± 0.78%) ~ 9.39s 9.60s p=0.748 n=6
Emit Time 2.63s (± 0.47%) 2.63s (± 0.48%) ~ 2.61s 2.64s p=0.553 n=6
Total Time 14.20s (± 0.69%) 14.24s (± 0.44%) ~ 14.12s 14.29s p=0.572 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,389k (± 0.01%) 347,376k (± 0.00%) ~ 347,354k 347,398k p=0.689 n=6
Parse Time 2.48s (± 0.42%) 2.48s (± 0.55%) ~ 2.46s 2.50s p=0.315 n=6
Bind Time 0.93s (± 0.56%) 0.93s (± 0.44%) ~ 0.92s 0.93s p=0.595 n=6
Check Time 7.01s (± 0.39%) 7.01s (± 0.29%) ~ 6.99s 7.05s p=0.685 n=6
Emit Time 4.07s (± 0.39%) 4.06s (± 0.43%) ~ 4.03s 4.08s p=0.324 n=6
Total Time 14.48s (± 0.15%) 14.47s (± 0.19%) ~ 14.44s 14.52s p=0.739 n=6
TFS - node (v18.15.0, x64)
Memory used 302,707k (± 0.00%) 302,684k (± 0.01%) ~ 302,664k 302,734k p=0.093 n=6
Parse Time 2.43s (± 0.67%) 2.42s (± 0.43%) ~ 2.40s 2.43s p=0.183 n=6
Bind Time 1.19s (± 0.53%) 1.20s (± 0.43%) ~ 1.19s 1.20s p=0.091 n=6
Check Time 7.46s (± 0.41%) 7.46s (± 0.39%) ~ 7.43s 7.51s p=0.872 n=6
Emit Time 4.27s (± 0.54%) 4.26s (± 0.49%) ~ 4.24s 4.30s p=0.808 n=6
Total Time 15.35s (± 0.16%) 15.34s (± 0.17%) ~ 15.29s 15.36s p=0.517 n=6
material-ui - node (v18.15.0, x64)
Memory used 509,890k (± 0.00%) 509,880k (± 0.01%) ~ 509,833k 509,944k p=0.261 n=6
Parse Time 2.66s (± 0.00%) 2.65s (± 0.66%) ~ 2.62s 2.67s p=0.599 n=6
Bind Time 0.98s (± 1.00%) 0.98s (± 1.06%) ~ 0.97s 1.00s p=0.343 n=6
Check Time 17.24s (± 0.27%) 17.30s (± 0.43%) ~ 17.22s 17.40s p=0.148 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.88s (± 0.25%) 20.94s (± 0.36%) ~ 20.84s 21.03s p=0.199 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,737,548k (± 0.00%) 1,737,539k (± 0.00%) ~ 1,737,513k 1,737,579k p=0.297 n=6
Parse Time 7.76s (± 0.18%) 7.80s (± 0.73%) ~ 7.72s 7.89s p=0.225 n=6
Bind Time 2.79s (± 0.35%) 2.81s (± 0.43%) ~ 2.79s 2.82s p=0.066 n=6
Check Time 66.39s (± 0.42%) 66.66s (± 0.43%) ~ 66.30s 66.98s p=0.173 n=6
Emit Time 0.16s (± 3.95%) 0.16s (± 3.29%) ~ 0.15s 0.16s p=0.386 n=6
Total Time 77.11s (± 0.36%) 77.42s (± 0.36%) ~ 77.05s 77.72s p=0.128 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,394,556k (± 0.04%) 2,393,488k (± 0.02%) ~ 2,392,868k 2,394,094k p=0.093 n=6
Parse Time 6.06s (± 0.82%) 6.03s (± 1.17%) ~ 5.94s 6.12s p=0.423 n=6
Bind Time 2.27s (± 1.35%) 2.28s (± 0.72%) ~ 2.25s 2.30s p=0.808 n=6
Check Time 39.53s (± 0.23%) 39.52s (± 0.34%) ~ 39.33s 39.68s p=0.936 n=6
Emit Time 3.13s (± 1.75%) 3.12s (± 1.26%) ~ 3.06s 3.16s p=0.936 n=6
Total Time 51.00s (± 0.29%) 50.96s (± 0.31%) ~ 50.81s 51.20s p=0.689 n=6
self-compiler - node (v18.15.0, x64)
Memory used 415,193k (± 0.01%) 415,193k (± 0.00%) ~ 415,182k 415,210k p=1.000 n=6
Parse Time 3.40s (± 0.98%) 3.43s (± 0.95%) ~ 3.39s 3.48s p=0.125 n=6
Bind Time 1.28s (± 0.64%) 1.28s (± 0.81%) ~ 1.26s 1.29s p=0.270 n=6
Check Time 17.99s (± 0.31%) 17.94s (± 0.34%) ~ 17.86s 18.01s p=0.106 n=6
Emit Time 1.33s (± 1.29%) 1.32s (± 1.70%) ~ 1.29s 1.34s p=0.870 n=6
Total Time 24.00s (± 0.34%) 23.97s (± 0.23%) ~ 23.88s 24.03s p=0.574 n=6
vscode - node (v18.15.0, x64)
Memory used 2,889,660k (± 0.00%) 2,889,668k (± 0.00%) ~ 2,889,630k 2,889,707k p=0.810 n=6
Parse Time 12.94s (± 0.30%) 12.95s (± 0.14%) ~ 12.93s 12.97s p=1.000 n=6
Bind Time 4.13s (± 0.33%) 4.11s (± 0.65%) ~ 4.08s 4.16s p=0.371 n=6
Check Time 71.27s (± 0.37%) 71.48s (± 0.20%) ~ 71.32s 71.69s p=0.173 n=6
Emit Time 19.46s (± 0.65%) 19.41s (± 0.49%) ~ 19.28s 19.52s p=0.423 n=6
Total Time 107.80s (± 0.34%) 107.95s (± 0.17%) ~ 107.72s 108.17s p=0.378 n=6
webpack - node (v18.15.0, x64)
Memory used 408,115k (± 0.01%) 408,104k (± 0.01%) ~ 408,074k 408,141k p=0.575 n=6
Parse Time 3.89s (± 0.50%) 3.91s (± 0.82%) ~ 3.87s 3.95s p=0.256 n=6
Bind Time 1.68s (± 0.75%) 1.68s (± 0.65%) ~ 1.66s 1.69s p=0.869 n=6
Check Time 16.71s (± 0.32%) 16.70s (± 0.37%) ~ 16.61s 16.77s p=0.628 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.28s (± 0.27%) 22.29s (± 0.34%) ~ 22.19s 22.40s p=0.936 n=6
xstate - node (v18.15.0, x64)
Memory used 513,031k (± 0.01%) 513,151k (± 0.01%) +120k (+ 0.02%) 513,075k 513,211k p=0.013 n=6
Parse Time 3.95s (± 0.59%) 3.96s (± 0.35%) ~ 3.95s 3.99s p=0.139 n=6
Bind Time 1.85s (± 0.93%) 1.86s (± 1.12%) ~ 1.82s 1.87s p=0.737 n=6
Check Time 3.36s (± 0.33%) 3.38s (± 0.79%) ~ 3.34s 3.41s p=0.293 n=6
Emit Time 0.09s (± 5.95%) 0.08s (± 6.19%) ~ 0.08s 0.09s p=0.311 n=6
Total Time 9.25s (± 0.39%) 9.28s (± 0.41%) ~ 9.21s 9.31s p=0.075 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - 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/57895/merge:

Something interesting changed - please have a look.

Details

pubkey/rxdb

8 of 11 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2322: Type '{ _deleted: boolean; }' is not assignable to type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>'.
  • error TS2345: Argument of type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>' is not assignable to parameter of type '{ _deleted: boolean; } | DeepReadonlyObject<{ _deleted: boolean; }> | Readonly<{ _deleted: boolean; }>'.

config/tsconfig.types.json

  • error TS2322: Type '{ _deleted: boolean; }' is not assignable to type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>'.
  • error TS2345: Argument of type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>' is not assignable to parameter of type '{ _deleted: boolean; } | DeepReadonlyObject<{ _deleted: boolean; }> | Readonly<{ _deleted: boolean; }>'.

@Andarist
Copy link
Contributor Author

@jakebailey could you rerun this on more top repos? I'd love to analyze this failure and I hope that running it on more repos might reveal some test cases that won't use recursive mapped types (it should be easier to analyze such ;p)

@jakebailey
Copy link
Member

@typescript-bot test top800

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2024

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

Command Status Results
test top800 ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

pubkey/rxdb

8 of 11 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2322: Type '{ _deleted: boolean; }' is not assignable to type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>'.
  • error TS2345: Argument of type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>' is not assignable to parameter of type '{ _deleted: boolean; } | DeepReadonlyObject<{ _deleted: boolean; }> | Readonly<{ _deleted: boolean; }>'.

config/tsconfig.types.json

  • error TS2322: Type '{ _deleted: boolean; }' is not assignable to type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>'.
  • error TS2345: Argument of type 'AnyDocFormat<RxDocType> | DeepReadonly<AnyDocFormat<RxDocType>>' is not assignable to parameter of type '{ _deleted: boolean; } | DeepReadonlyObject<{ _deleted: boolean; }> | Readonly<{ _deleted: boolean; }>'.

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
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

4 participants