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 intersected reverse mapped types #52062

Closed

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jan 1, 2023

This doesn't exactly fix the code reported in #52047 but it makes it possible to rewrite the whole thing with intersected mapped types.

I still think that the better solution would be the one that I've proposed here but that doesn't mean that intersections like this can't work. Those are orthogonal capabilities - it's a different thing to infer a single type param based on multiple "partials" and it's a different thing to infer multiple type params like here. Both can co-exist.

The reverse mapped types are an incredibly useful technique. They allow us to infer types for something (like a callback's argument) based on a type in another property of the same tuple element (or within the same property value of a mapped object).

So for example this works (TS playground):

type TupleOptions<T extends any[]> = {
  [K in keyof T]: {
    inputData: T[K];
    handler: (t: T[K]) => void;
  };
};

declare function fooWithTuple<T extends any[]>(
  bar: [...TupleOptions<T>]
): void;

fooWithTuple([
  {
    inputData: "awesome",
    handler: (x) => {
      x; // string
    },
  },
]);

Unfortunately, they fall short today when trying to introduce more "relationships" like this for a given element~. Allowing to infer type params based on intersected mapped types would essentially lift this limitation and enable people to rewrite some crazy types with a much simpler technique (I'm specifically thinking here about very popular React Query and Redux Toolkit but the technique could be utilized in a lot of ways).

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 1, 2023
@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.

return substituteIndexedMappedType(mappedType, propertyNameType);
}
});
return newTypes.length ? getIntersectionType(newTypes) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

This will quietly elide intersection members whose substitution fails the isTypeAssignableTo(propertyNameType, constraintOfConstraint) check. I honestly can't think of how that could occur offhand, but I think to better mimic old behavior, since intersections are structured types, and would previously only take the other branch. If newTypes.length !== (t.flags & TypeFlags.Intersection ? (t as IntersectionType).types : [t]).length, we need to fall through to the StructuredType fallback below.

Copy link
Contributor Author

@Andarist Andarist Mar 18, 2023

Choose a reason for hiding this comment

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

I've tried a couple of things to hit such a case and I can't think of any. I can introduce the proposed change but personally I think that it should be accompanied with a test case. I understand the desire to match the old behavior but:

  1. if we manage to grab a concrete property in the branch responsible for structured types then this is basically the same thing as substituting indexed mapped type (so doing it within this branch responsible for generic mapped types leads to the same results already)
  2. if we manage to grab some index info there then I find it extremely unlikely there is a way to reach that branch of code if all intersected mapped type failed isTypeAssignableTo(propertyNameType, constraintOfConstraint) check. In a lot of situations, the constraintOfConstraint is already string | number | symbol and even when it's not... the index type has to come from one of the intersected members, so some of them had to pass this isTypeAssignableTo check and thus newTypes wouldn't be empty.
  3. The isTupleType is just impossible to be hit by intersections

So, all in all, I think that the requested change wouldn't be meaningful - but, ofc, I could be wrong here. And even if such intersections could today return something meaningful then that, I think, would be inconsistent with the isGenericMappedType(t) && !t.declaration.nameType branch. That's because that branch doesn't fallback to the branch related to structured types - even if isTypeAssignableTo(propertyNameType, constraintOfConstraint). So if this doesn't happen for generic mapped types - why should it happen for intersected ones? That would be an inconsistent behavior to me.

@Andarist
Copy link
Contributor Author

@jakebailey could you prepare a playground for this one? 🙏 :)

@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 16, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at 25af013. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 16, 2023

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/149654/artifacts?artifactName=tgz&fileId=ACE7E2484352A2A007E36B82EDFDE99E1A6E29A91019AB749BF60A12621FF49902&fileName=/typescript-5.1.0-insiders.20230316.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@weswigham
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 56f12bc. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

Update: The results are in!

if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
return substituteIndexedMappedType(t, propertyNameType);
}
if (everyContainedType(t, t => isGenericMappedType(t) && !t.declaration.nameType)) {
Copy link
Member

Choose a reason for hiding this comment

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

Actually, thinking about it, shouldn't we just do this for each isGenericMappedType(t) && !t.declaration.nameType within an intersection, and not only do this substitution if every member is such? (And still do the other StructuredType behaviors for other intersection members). This way a Results<T> & Errors<E> & {x?: string} still works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, so I actually... have another PR that does exactly that 🤣 This one here is intentionally conservative when it comes to the scope of the change, especially since some other changes (outside of getTypeOfPropertyOfContextualType) had to be made to support this use case. So it's not like that other PR completely replaces this one.

The PR in question is this: #52095 . Actually, one version of it was already merged into 4.8-beta but it was reverted cause @reduxjs/toolkit regressed with it. However, it only regressed because of how I've handled intersections of types with concrete properties with types with index signatures.

In the original version of this PR (#48668) I decided to prefer concrete properties over index signatures, so (IIRC) if one of the intersected members had a concrete property for the requested one then index signatures on other intersected members were skipped over. This wasn't strictly needed to fix the issue that I was fixing but it was something that made sense to me at the time.

Either way... if you could take a look at that other PR (#52095), I would highly appreciate it. There is some funky stuff going on there with index signatures and that part is not correct - the problem is that I'm not sure how to adjust it since I'm not sure what exact effect are we aiming for there. Mixing index signatures with concrete properties through intersections is weird (like { foo: number } & { [key: string]: boolean }). This particular place in the code doesn't exactly deal with concrete types either... so perhaps a guiding principle should be that properties should be pulled from types that can still resolve to concrete properties? I'm not sure how checking that would look like though - so perhaps we should just ignore it and always pull from index signatures?

Copy link
Member

Choose a reason for hiding this comment

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

Mmmmm, I'd rather not take this one with a known drawback like that - maybe it's best to just merge the two PRs, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To keep the spirit of minimal changes I would probably prefer to keep them separate (if you prefer to merge them, then I won't oppose it though, at the end of the day I'd like both improvements to find their way into the language :P). I don't mind this one staying on the sidelines and waiting for the other one to land though. I would love for the other one to get some traction in terms of being reviewed 😜

Copy link
Member

Choose a reason for hiding this comment

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

I think that the common improvements need to be on both PRs (and the conflicts can be resolved later), or both PRs should be merged, yeah.

@typescript-bot
Copy link
Collaborator

Hey @weswigham, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

@weswigham Here are the results of running the top-repos suite comparing main and refs/pull/52062/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..52062
Metric main 52062 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 361,691k (± 0.01%) 361,700k (± 0.01%) ~ 361,634k 361,740k p=0.471 n=6
Parse Time 3.38s (± 0.95%) 3.38s (± 1.08%) ~ 3.33s 3.43s p=1.000 n=6
Bind Time 1.11s (± 0.68%) 1.12s (± 0.75%) ~ 1.11s 1.13s p=0.652 n=6
Check Time 8.70s (± 0.59%) 8.67s (± 0.19%) ~ 8.66s 8.69s p=0.511 n=6
Emit Time 7.44s (± 0.91%) 7.42s (± 0.56%) ~ 7.36s 7.47s p=0.810 n=6
Total Time 20.64s (± 0.72%) 20.59s (± 0.22%) ~ 20.55s 20.65s p=1.000 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 193,641k (± 1.58%) 190,851k (± 0.01%) ~ 190,832k 190,884k p=0.378 n=6
Parse Time 1.51s (± 1.08%) 1.50s (± 0.73%) ~ 1.49s 1.52s p=0.161 n=6
Bind Time 0.77s (± 0.82%) 0.77s (± 0.67%) ~ 0.76s 0.77s p=0.386 n=6
Check Time 9.47s (± 0.88%) 9.46s (± 1.10%) ~ 9.34s 9.60s p=0.936 n=6
Emit Time 2.74s (± 0.80%) 2.73s (± 1.02%) ~ 2.69s 2.77s p=0.625 n=6
Total Time 14.49s (± 0.76%) 14.46s (± 0.77%) ~ 14.31s 14.59s p=0.689 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,268k (± 0.01%) 346,317k (± 0.01%) ~ 346,246k 346,366k p=0.093 n=6
Parse Time 2.59s (± 0.53%) 2.59s (± 1.22%) ~ 2.56s 2.63s p=0.570 n=6
Bind Time 1.00s (± 0.83%) 1.01s (± 1.25%) ~ 1.00s 1.03s p=0.530 n=6
Check Time 7.02s (± 0.79%) 7.02s (± 0.44%) ~ 6.99s 7.07s p=0.935 n=6
Emit Time 4.23s (± 0.29%) 4.24s (± 0.52%) ~ 4.21s 4.27s p=0.254 n=6
Total Time 14.85s (± 0.42%) 14.86s (± 0.53%) ~ 14.78s 14.96s p=0.872 n=6
TFS - node (v18.10.0, x64)
Memory used 300,482k (± 0.01%) 300,478k (± 0.01%) ~ 300,440k 300,527k p=1.000 n=6
Parse Time 2.07s (± 1.21%) 2.07s (± 0.79%) ~ 2.04s 2.08s p=0.802 n=6
Bind Time 1.15s (± 0.55%) 1.14s (± 0.91%) -0.01s (- 1.16%) 1.12s 1.15s p=0.028 n=6
Check Time 6.51s (± 0.55%) 6.53s (± 0.22%) ~ 6.51s 6.55s p=0.295 n=6
Emit Time 3.87s (± 0.92%) 3.87s (± 0.44%) ~ 3.84s 3.89s p=0.746 n=6
Total Time 13.60s (± 0.43%) 13.60s (± 0.16%) ~ 13.56s 13.62s p=0.936 n=6
material-ui - node (v18.10.0, x64)
Memory used 477,165k (± 0.01%) 479,140k (± 0.00%) +1,975k (+ 0.41%) 479,114k 479,168k p=0.005 n=6
Parse Time 3.08s (± 0.83%) 3.04s (± 1.83%) ~ 2.94s 3.09s p=0.332 n=6
Bind Time 0.91s (± 0.90%) 0.94s (± 7.50%) ~ 0.90s 1.08s p=0.383 n=6
Check Time 16.92s (± 0.19%) 17.20s (± 0.54%) +0.29s (+ 1.70%) 17.03s 17.28s p=0.005 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.90s (± 0.18%) 21.18s (± 0.46%) +0.28s (+ 1.35%) 21.01s 21.29s p=0.005 n=6
xstate - node (v18.10.0, x64)
Memory used 552,879k (± 0.01%) 552,957k (± 0.02%) ~ 552,869k 553,125k p=0.173 n=6
Parse Time 3.79s (± 0.70%) 3.78s (± 0.48%) ~ 3.76s 3.81s p=0.805 n=6
Bind Time 1.71s (± 0.61%) 1.70s (± 0.58%) ~ 1.68s 1.71s p=0.343 n=6
Check Time 2.75s (± 0.89%) 2.73s (± 0.85%) ~ 2.71s 2.77s p=0.288 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.32s (± 0.37%) 8.30s (± 0.31%) ~ 8.27s 8.33s p=0.169 n=6
Angular - node (v16.17.1, x64)
Memory used 361,054k (± 0.01%) 361,039k (± 0.01%) ~ 360,993k 361,108k p=0.689 n=6
Parse Time 3.51s (± 0.47%) 3.51s (± 0.66%) ~ 3.49s 3.55s p=0.805 n=6
Bind Time 1.19s (± 0.34%) 1.18s (± 0.71%) ~ 1.18s 1.20s p=0.285 n=6
Check Time 9.53s (± 0.31%) 9.55s (± 0.56%) ~ 9.50s 9.65s p=0.629 n=6
Emit Time 7.92s (± 0.30%) 7.95s (± 0.76%) ~ 7.87s 8.03s p=0.468 n=6
Total Time 22.16s (± 0.16%) 22.20s (± 0.50%) ~ 22.11s 22.41s p=0.687 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,538k (± 0.02%) 192,612k (± 0.03%) +74k (+ 0.04%) 192,572k 192,718k p=0.010 n=6
Parse Time 1.59s (± 1.62%) 1.57s (± 1.91%) ~ 1.52s 1.60s p=0.326 n=6
Bind Time 0.83s (± 0.62%) 0.82s (± 0.63%) -0.01s (- 1.21%) 0.81s 0.82s p=0.018 n=6
Check Time 10.21s (± 1.41%) 10.17s (± 0.68%) ~ 10.09s 10.26s p=0.810 n=6
Emit Time 3.00s (± 1.13%) 2.98s (± 0.89%) ~ 2.96s 3.03s p=0.334 n=6
Total Time 15.63s (± 1.16%) 15.55s (± 0.42%) ~ 15.46s 15.62s p=0.421 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,542k (± 0.01%) 345,554k (± 0.00%) ~ 345,523k 345,570k p=0.377 n=6
Parse Time 2.73s (± 0.72%) 2.72s (± 0.39%) ~ 2.70s 2.73s p=0.067 n=6
Bind Time 1.09s (± 0.37%) 1.09s (± 0.37%) ~ 1.08s 1.09s p=0.218 n=6
Check Time 7.71s (± 0.52%) 7.71s (± 0.28%) ~ 7.69s 7.75s p=0.809 n=6
Emit Time 4.48s (± 0.52%) 4.45s (± 0.46%) -0.04s (- 0.78%) 4.42s 4.47s p=0.037 n=6
Total Time 16.02s (± 0.31%) 15.96s (± 0.24%) ~ 15.93s 16.03s p=0.064 n=6
TFS - node (v16.17.1, x64)
Memory used 299,784k (± 0.01%) 299,813k (± 0.01%) ~ 299,777k 299,869k p=0.296 n=6
Parse Time 2.17s (± 0.47%) 2.17s (± 0.48%) ~ 2.15s 2.18s p=0.241 n=6
Bind Time 1.24s (± 0.66%) 1.24s (± 0.51%) ~ 1.23s 1.25s p=0.432 n=6
Check Time 7.17s (± 0.34%) 7.20s (± 0.51%) ~ 7.15s 7.25s p=0.145 n=6
Emit Time 4.34s (± 0.54%) 4.34s (± 0.59%) ~ 4.30s 4.36s p=0.808 n=6
Total Time 14.93s (± 0.20%) 14.95s (± 0.42%) ~ 14.89s 15.03s p=1.000 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,421k (± 0.01%) 478,382k (± 0.01%) +1,962k (+ 0.41%) 478,360k 478,426k p=0.005 n=6
Parse Time 3.19s (± 1.21%) 3.20s (± 0.90%) ~ 3.15s 3.23s p=0.627 n=6
Bind Time 0.97s (± 1.81%) 0.96s (± 2.02%) ~ 0.95s 1.00s p=0.351 n=6
Check Time 17.93s (± 0.42%) 18.12s (± 0.41%) +0.18s (+ 1.02%) 18.02s 18.22s p=0.006 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.09s (± 0.42%) 22.28s (± 0.31%) +0.19s (+ 0.84%) 22.19s 22.38s p=0.008 n=6
xstate - node (v16.17.1, x64)
Memory used 550,521k (± 0.01%) 550,614k (± 0.02%) ~ 550,470k 550,779k p=0.149 n=6
Parse Time 3.96s (± 0.26%) 3.94s (± 0.39%) -0.02s (- 0.42%) 3.92s 3.96s p=0.050 n=6
Bind Time 1.80s (± 0.55%) 1.80s (± 0.45%) ~ 1.79s 1.81s p=0.394 n=6
Check Time 2.97s (± 0.84%) 2.97s (± 0.58%) ~ 2.95s 3.00s p=0.870 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.82s (± 0.38%) 8.80s (± 0.25%) ~ 8.76s 8.82s p=0.295 n=6
Angular - node (v14.15.1, x64)
Memory used 354,888k (± 0.01%) 354,882k (± 0.00%) ~ 354,871k 354,897k p=0.936 n=6
Parse Time 3.60s (± 0.85%) 3.58s (± 0.39%) ~ 3.56s 3.60s p=0.222 n=6
Bind Time 1.23s (± 0.33%) 1.23s (± 0.33%) ~ 1.23s 1.24s p=1.000 n=6
Check Time 9.83s (± 0.37%) 9.85s (± 0.19%) ~ 9.83s 9.87s p=0.164 n=6
Emit Time 8.40s (± 0.46%) 8.38s (± 0.79%) ~ 8.30s 8.48s p=0.630 n=6
Total Time 23.06s (± 0.17%) 23.05s (± 0.29%) ~ 22.99s 23.17s p=0.376 n=6
Compiler-Unions - node (v14.15.1, x64)
Memory used 187,781k (± 0.01%) 187,869k (± 0.01%) +88k (+ 0.05%) 187,844k 187,884k p=0.005 n=6
Parse Time 1.61s (± 0.65%) 1.60s (± 0.56%) ~ 1.59s 1.61s p=0.452 n=6
Bind Time 0.85s (± 0.48%) 0.84s (± 0.61%) ~ 0.84s 0.85s p=0.112 n=6
Check Time 10.29s (± 0.43%) 10.25s (± 0.29%) ~ 10.21s 10.28s p=0.106 n=6
Emit Time 3.12s (± 0.39%) 3.13s (± 0.65%) ~ 3.09s 3.14s p=0.316 n=6
Total Time 15.87s (± 0.28%) 15.82s (± 0.27%) ~ 15.75s 15.86s p=0.127 n=6
Monaco - node (v14.15.1, x64)
Memory used 340,557k (± 0.01%) 340,529k (± 0.00%) ~ 340,507k 340,551k p=0.054 n=6
Parse Time 2.83s (± 0.66%) 2.83s (± 0.66%) ~ 2.81s 2.86s p=1.000 n=6
Bind Time 1.09s (± 0.47%) 1.09s (± 0.75%) ~ 1.08s 1.10s p=0.929 n=6
Check Time 8.11s (± 0.52%) 8.08s (± 0.43%) ~ 8.05s 8.13s p=0.222 n=6
Emit Time 4.69s (± 0.37%) 4.67s (± 0.61%) ~ 4.64s 4.71s p=0.192 n=6
Total Time 16.72s (± 0.44%) 16.68s (± 0.42%) ~ 16.60s 16.77s p=0.336 n=6
TFS - node (v14.15.1, x64)
Memory used 294,884k (± 0.00%) 294,896k (± 0.00%) +12k (+ 0.00%) 294,877k 294,912k p=0.045 n=6
Parse Time 2.41s (± 1.09%) 2.39s (± 0.82%) ~ 2.36s 2.42s p=0.292 n=6
Bind Time 1.07s (± 0.78%) 1.06s (± 0.00%) ~ 1.06s 1.06s p=0.176 n=6
Check Time 7.52s (± 0.82%) 7.49s (± 0.40%) ~ 7.47s 7.55s p=0.572 n=6
Emit Time 4.31s (± 0.76%) 4.29s (± 0.75%) ~ 4.25s 4.33s p=0.198 n=6
Total Time 15.30s (± 0.29%) 15.23s (± 0.40%) ~ 15.14s 15.31s p=0.073 n=6
material-ui - node (v14.15.1, x64)
Memory used 471,961k (± 0.01%) 473,985k (± 0.01%) +2,024k (+ 0.43%) 473,941k 474,005k p=0.005 n=6
Parse Time 3.35s (± 0.56%) 3.35s (± 0.35%) ~ 3.33s 3.36s p=0.621 n=6
Bind Time 1.01s (± 1.02%) 1.00s (± 0.81%) ~ 0.99s 1.01s p=0.546 n=6
Check Time 18.87s (± 1.08%) 19.08s (± 0.35%) ~ 19.00s 19.17s p=0.065 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 23.22s (± 0.83%) 23.43s (± 0.26%) ~ 23.35s 23.50s p=0.066 n=6
xstate - node (v14.15.1, x64)
Memory used 539,124k (± 0.00%) 539,139k (± 0.00%) ~ 539,118k 539,159k p=0.229 n=6
Parse Time 4.20s (± 0.29%) 4.21s (± 0.56%) ~ 4.16s 4.23s p=0.549 n=6
Bind Time 1.66s (± 0.49%) 1.66s (± 0.25%) ~ 1.65s 1.66s p=0.206 n=6
Check Time 3.13s (± 0.26%) 3.13s (± 0.34%) ~ 3.11s 3.14s p=0.137 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 9.10s (± 0.18%) 9.08s (± 0.27%) ~ 9.04s 9.11s p=0.168 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52062 6
Baseline main 6

TSServer

Comparison Report - main..52062
Metric main 52062 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,400ms (± 0.97%) 2,385ms (± 0.54%) ~ 2,371ms 2,405ms p=0.173 n=6
Req 2 - geterr 5,407ms (± 0.37%) 5,392ms (± 0.44%) ~ 5,347ms 5,419ms p=0.261 n=6
Req 3 - references 337ms (± 0.60%) 337ms (± 0.93%) ~ 332ms 341ms p=0.511 n=6
Req 4 - navto 280ms (± 0.67%) 280ms (± 0.44%) ~ 278ms 281ms p=1.000 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 82ms (± 3.45%) 76ms (± 6.19%) 🟩-7ms (- 7.93%) 66ms 78ms p=0.007 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,511ms (± 0.86%) 2,506ms (± 1.43%) ~ 2,475ms 2,561ms p=0.630 n=6
Req 2 - geterr 4,050ms (± 0.54%) 4,051ms (± 0.89%) ~ 4,003ms 4,103ms p=1.000 n=6
Req 3 - references 350ms (± 0.98%) 353ms (± 0.77%) ~ 351ms 357ms p=0.243 n=6
Req 4 - navto 294ms (± 1.11%) 294ms (± 0.67%) ~ 290ms 296ms p=1.000 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 75ms (± 7.49%) 79ms (± 3.29%) ~ 75ms 83ms p=0.293 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,030ms (± 0.73%) 3,022ms (± 0.71%) ~ 3,003ms 3,060ms p=0.521 n=6
Req 2 - geterr 1,571ms (± 1.21%) 1,552ms (± 1.03%) ~ 1,530ms 1,572ms p=0.173 n=6
Req 3 - references 108ms (± 1.27%) 107ms (± 1.24%) ~ 105ms 109ms p=0.676 n=6
Req 4 - navto 355ms (± 0.58%) 354ms (± 0.66%) ~ 353ms 359ms p=0.290 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 391ms (± 5.35%) 380ms (± 1.31%) ~ 371ms 385ms p=0.261 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,497ms (± 0.69%) 2,503ms (± 0.70%) ~ 2,483ms 2,525ms p=0.378 n=6
Req 2 - geterr 5,816ms (± 0.62%) 5,777ms (± 0.53%) ~ 5,735ms 5,820ms p=0.093 n=6
Req 3 - references 349ms (± 1.24%) 347ms (± 0.79%) ~ 343ms 351ms p=0.334 n=6
Req 4 - navto 279ms (± 1.50%) 277ms (± 1.13%) ~ 273ms 281ms p=0.422 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 74ms (± 0.55%) 74ms (± 0.70%) ~ 73ms 74ms p=0.114 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,684ms (± 0.70%) 2,705ms (± 0.85%) ~ 2,684ms 2,743ms p=0.128 n=6
Req 2 - geterr 4,389ms (± 0.43%) 4,404ms (± 0.45%) ~ 4,387ms 4,435ms p=0.109 n=6
Req 3 - references 359ms (± 0.58%) 359ms (± 0.72%) ~ 355ms 362ms p=0.935 n=6
Req 4 - navto 290ms (± 0.67%) 290ms (± 0.65%) ~ 287ms 292ms p=1.000 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 75ms (± 4.84%) 77ms (± 4.31%) ~ 71ms 80ms p=0.164 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,170ms (± 0.54%) 3,176ms (± 0.36%) ~ 3,167ms 3,198ms p=0.378 n=6
Req 2 - geterr 1,751ms (± 0.42%) 1,774ms (± 1.08%) +23ms (+ 1.33%) 1,755ms 1,797ms p=0.019 n=6
Req 3 - references 115ms (± 2.18%) 114ms (± 0.74%) ~ 112ms 114ms p=0.326 n=6
Req 4 - navto 340ms (± 0.22%) 339ms (± 0.34%) ~ 337ms 340ms p=0.120 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 393ms (± 0.86%) 396ms (± 0.57%) ~ 393ms 398ms p=0.169 n=6
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,600ms (± 0.45%) 2,604ms (± 0.45%) ~ 2,593ms 2,624ms p=0.630 n=6
Req 2 - geterr 6,189ms (± 0.61%) 6,205ms (± 0.34%) ~ 6,167ms 6,228ms p=0.471 n=6
Req 3 - references 365ms (± 0.87%) 367ms (± 1.39%) ~ 363ms 375ms p=0.935 n=6
Req 4 - navto 277ms (± 0.42%) 279ms (± 1.17%) ~ 276ms 285ms p=0.800 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 102ms (± 0.80%) 102ms (± 2.70%) ~ 96ms 103ms p=1.000 n=6
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,817ms (± 0.59%) 2,829ms (± 0.35%) ~ 2,819ms 2,848ms p=0.230 n=6
Req 2 - geterr 4,473ms (± 0.42%) 4,548ms (± 2.66%) ~ 4,437ms 4,707ms p=0.423 n=6
Req 3 - references 409ms (± 7.19%) 401ms (± 7.11%) ~ 373ms 431ms p=1.000 n=6
Req 4 - navto 291ms (± 1.35%) 291ms (± 1.45%) ~ 285ms 297ms p=1.000 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 87ms (± 6.98%) 82ms (±10.08%) ~ 73ms 93ms p=0.517 n=6
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 3,459ms (± 0.69%) 3,455ms (± 0.65%) ~ 3,429ms 3,482ms p=0.810 n=6
Req 2 - geterr 1,868ms (± 0.90%) 1,871ms (± 1.13%) ~ 1,842ms 1,894ms p=0.630 n=6
Req 3 - references 128ms (± 1.74%) 126ms (± 2.32%) ~ 124ms 132ms p=0.142 n=6
Req 4 - navto 370ms (± 0.48%) 372ms (± 0.52%) ~ 369ms 374ms p=0.073 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 414ms (± 0.44%) 412ms (± 0.74%) ~ 408ms 417ms p=0.195 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52062 6
Baseline main 6

Startup

Comparison Report - main..52062
Metric main 52062 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 141.97ms (± 0.19%) 141.78ms (± 0.17%) -0.18ms (- 0.13%) 141.17ms 144.35ms p=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 227.27ms (± 0.24%) 227.18ms (± 0.15%) -0.08ms (- 0.04%) 226.29ms 232.21ms p=0.050 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 229.99ms (± 0.38%) 228.88ms (± 0.17%) -1.11ms (- 0.48%) 227.98ms 235.81ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 211.75ms (± 0.42%) 209.72ms (± 0.18%) -2.03ms (- 0.96%) 208.84ms 216.50ms p=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 52062 6
Baseline main 6

Developer Information:

Download Benchmark

@Andarist
Copy link
Contributor Author

Superseded by #52095

@Andarist Andarist closed this Jul 30, 2024
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: Done
Development

Successfully merging this pull request may close these issues.

5 participants