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

Strip literal freshness when contextually typed by instantiable type that has return mapper constraint inferences #50759

Closed
wants to merge 3 commits into from

Conversation

andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Sep 13, 2022

From the test:

interface Guard<T> {
  (val: unknown): val is T;
}

type ObjectGuard<T> = {
  [key in keyof T]: Guard<T[key]>;
};

declare function createObjectGuard<T>(guard: ObjectGuard<T>): (val: unknown) => val is T;

declare function asLiteral<T extends (string | boolean | number)[]>(...literals: T): (val: unknown) => val is T[number]

// See type of `isWorking` - should include the type key as a union of strings
const isWorking = createObjectGuard({
  type: asLiteral('these', 'should', 'be', 'a', 'union'),
});

When inferring T for asLiteral(...), we get the type of each argument (starting with "these") with the contextual type T[0], T[1], and so on. We use the contextual type to determine whether to widen or strip freshness from literal types, but we try to instantiate it first, using inferences made from the return type. The return type inference turns out to map the T of asLiteral to the T of createObjectGuard (which, uh, seems wrong, but doesn’t actually matter here), and since the former is not assignable to the latter, the inference goes to the constraint, (string | boolean | number)[]. So the contextual type T[0] is instantiated to string | number (through some special unrelated logic to filter booleans out of union contextual types). That type is not a literal type, so "these" remains fresh, allowing it to widen to string as the spread argument. The weird thing is, if we had just asked whether "these" was a literal type of the contextual type T[0] where T extends (string | boolean | number)[] instead of eagerly instantiating that type, we would have said yes; when an instantiable type is constrained to a primitive, we want to preserve the literalness of arguments it contextually types. So, this PR asks whether a literal type could be a literal of its contextual type, instantiated or uninstantiated.

I think a possible alternative would be to discard contextual type instantiations where the return type mapper simply produces an inference to the constraint of the type parameter it’s inferring, indicating that nothing useful came from trying to infer from the return type.

Fixes #50635
Fixes #50787

…that has return mapper constraint inferences
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 13, 2022
@andrewbranch
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

Heya @andrewbranch, I've started to run the perf test suite on this PR at 410d2f7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

Heya @andrewbranch, I've started to run the diff-based user code test suite on this PR at 410d2f7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the user test suite comparing main and refs/pull/50759/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..50759
Metric main 50759 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 363,254k (± 0.03%) 363,355k (± 0.02%) +101k (+ 0.03%) 363,133k 363,479k
Parse Time 2.10s (± 0.74%) 2.09s (± 0.57%) -0.01s (- 0.57%) 2.06s 2.11s
Bind Time 0.79s (± 0.75%) 0.79s (± 0.92%) -0.01s (- 0.76%) 0.78s 0.81s
Check Time 6.19s (± 0.29%) 6.18s (± 0.52%) -0.01s (- 0.18%) 6.10s 6.23s
Emit Time 6.04s (± 0.65%) 6.02s (± 1.08%) -0.02s (- 0.30%) 5.87s 6.16s
Total Time 15.13s (± 0.42%) 15.08s (± 0.54%) -0.05s (- 0.32%) 14.90s 15.25s
Compiler-Unions - node (v10.16.3, x64)
Memory used 205,810k (± 0.38%) 205,926k (± 0.28%) +116k (+ 0.06%) 203,607k 206,310k
Parse Time 0.83s (± 0.99%) 0.84s (± 0.88%) +0.01s (+ 0.72%) 0.83s 0.86s
Bind Time 0.48s (± 0.83%) 0.47s (± 1.10%) -0.01s (- 2.08%) 0.46s 0.48s
Check Time 8.49s (± 1.07%) 8.58s (± 0.63%) +0.09s (+ 1.10%) 8.45s 8.69s
Emit Time 2.44s (± 1.84%) 2.43s (± 0.91%) -0.01s (- 0.53%) 2.37s 2.47s
Total Time 12.24s (± 0.75%) 12.32s (± 0.68%) +0.08s (+ 0.65%) 12.11s 12.50s
Monaco - node (v10.16.3, x64)
Memory used 344,778k (± 0.02%) 344,792k (± 0.02%) +14k (+ 0.00%) 344,661k 344,991k
Parse Time 1.61s (± 0.75%) 1.61s (± 0.70%) +0.01s (+ 0.31%) 1.58s 1.64s
Bind Time 0.71s (± 1.08%) 0.71s (± 1.27%) 0.00s ( 0.00%) 0.70s 0.74s
Check Time 6.24s (± 0.54%) 6.23s (± 0.39%) -0.01s (- 0.18%) 6.18s 6.28s
Emit Time 3.23s (± 1.11%) 3.18s (± 0.81%) -0.04s (- 1.36%) 3.13s 3.25s
Total Time 11.78s (± 0.28%) 11.73s (± 0.41%) -0.05s (- 0.43%) 11.62s 11.85s
TFS - node (v10.16.3, x64)
Memory used 306,015k (± 0.02%) 305,972k (± 0.02%) -43k (- 0.01%) 305,819k 306,080k
Parse Time 1.30s (± 0.68%) 1.30s (± 0.70%) +0.00s (+ 0.15%) 1.28s 1.32s
Bind Time 0.68s (± 0.54%) 0.67s (± 0.66%) -0.00s (- 0.59%) 0.66s 0.68s
Check Time 5.53s (± 0.57%) 5.49s (± 0.20%) -0.04s (- 0.67%) 5.47s 5.52s
Emit Time 3.37s (± 1.23%) 3.35s (± 1.13%) -0.02s (- 0.53%) 3.25s 3.42s
Total Time 10.88s (± 0.54%) 10.82s (± 0.36%) -0.06s (- 0.54%) 10.73s 10.90s
material-ui - node (v10.16.3, x64)
Memory used 459,202k (± 0.01%) 459,197k (± 0.02%) -5k (- 0.00%) 459,042k 459,441k
Parse Time 1.83s (± 0.48%) 1.84s (± 0.85%) +0.01s (+ 0.27%) 1.82s 1.87s
Bind Time 0.58s (± 2.14%) 0.58s (± 2.02%) -0.00s (- 0.51%) 0.56s 0.60s
Check Time 15.80s (± 0.60%) 15.74s (± 0.67%) -0.06s (- 0.39%) 15.51s 15.98s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 18.22s (± 0.53%) 18.16s (± 0.60%) -0.06s (- 0.33%) 17.91s 18.40s
xstate - node (v10.16.3, x64)
Memory used 584,151k (± 0.02%) 584,082k (± 0.01%) -68k (- 0.01%) 583,927k 584,192k
Parse Time 2.62s (± 0.24%) 2.62s (± 0.40%) +0.00s (+ 0.04%) 2.60s 2.65s
Bind Time 0.92s (± 0.52%) 0.92s (± 0.57%) +0.00s (+ 0.22%) 0.90s 0.93s
Check Time 1.61s (± 0.38%) 1.61s (± 0.70%) 0.00s ( 0.00%) 1.59s 1.63s
Emit Time 0.07s (± 3.14%) 0.07s (± 0.00%) -0.00s (- 1.41%) 0.07s 0.07s
Total Time 5.22s (± 0.21%) 5.22s (± 0.37%) +0.00s (+ 0.08%) 5.18s 5.27s
Angular - node (v12.1.0, x64)
Memory used 340,840k (± 0.02%) 340,854k (± 0.03%) +14k (+ 0.00%) 340,709k 341,170k
Parse Time 2.09s (± 0.74%) 2.08s (± 0.60%) -0.01s (- 0.29%) 2.05s 2.10s
Bind Time 0.77s (± 0.68%) 0.78s (± 1.44%) +0.01s (+ 0.78%) 0.76s 0.81s
Check Time 5.84s (± 0.91%) 5.81s (± 0.44%) -0.03s (- 0.50%) 5.76s 5.86s
Emit Time 6.21s (± 0.57%) 6.24s (± 1.50%) +0.03s (+ 0.53%) 6.13s 6.58s
Total Time 14.91s (± 0.50%) 14.92s (± 0.64%) +0.01s (+ 0.06%) 14.80s 15.26s
Compiler-Unions - node (v12.1.0, x64)
Memory used 193,367k (± 0.56%) 193,434k (± 0.47%) +67k (+ 0.03%) 190,777k 194,207k
Parse Time 0.82s (± 0.81%) 0.83s (± 0.70%) +0.00s (+ 0.49%) 0.82s 0.84s
Bind Time 0.47s (± 1.10%) 0.47s (± 1.01%) +0.00s (+ 0.42%) 0.46s 0.48s
Check Time 6.74s (± 0.92%) 6.72s (± 0.69%) -0.02s (- 0.22%) 6.60s 6.84s
Emit Time 2.42s (± 0.87%) 2.44s (± 1.51%) +0.03s (+ 1.12%) 2.38s 2.56s
Total Time 10.45s (± 0.71%) 10.47s (± 0.64%) +0.02s (+ 0.19%) 10.29s 10.62s
Monaco - node (v12.1.0, x64)
Memory used 327,765k (± 0.03%) 327,783k (± 0.02%) +18k (+ 0.01%) 327,661k 327,988k
Parse Time 1.59s (± 0.66%) 1.58s (± 0.59%) -0.01s (- 0.57%) 1.56s 1.60s
Bind Time 0.70s (± 0.85%) 0.70s (± 0.83%) +0.00s (+ 0.14%) 0.69s 0.71s
Check Time 5.83s (± 0.54%) 5.83s (± 0.40%) +0.00s (+ 0.09%) 5.79s 5.90s
Emit Time 3.26s (± 0.49%) 3.27s (± 0.51%) +0.01s (+ 0.21%) 3.24s 3.32s
Total Time 11.38s (± 0.34%) 11.38s (± 0.31%) +0.01s (+ 0.05%) 11.32s 11.47s
TFS - node (v12.1.0, x64)
Memory used 290,586k (± 0.07%) 290,586k (± 0.02%) +0k (+ 0.00%) 290,464k 290,708k
Parse Time 1.31s (± 1.17%) 1.31s (± 0.94%) -0.00s (- 0.23%) 1.28s 1.33s
Bind Time 0.68s (± 0.89%) 0.68s (± 1.21%) +0.00s (+ 0.30%) 0.66s 0.69s
Check Time 5.39s (± 0.67%) 5.39s (± 0.36%) +0.00s (+ 0.07%) 5.35s 5.43s
Emit Time 3.44s (± 0.92%) 3.45s (± 1.41%) +0.01s (+ 0.35%) 3.37s 3.61s
Total Time 10.81s (± 0.52%) 10.83s (± 0.48%) +0.02s (+ 0.16%) 10.70s 10.98s
material-ui - node (v12.1.0, x64)
Memory used 438,383k (± 0.01%) 438,229k (± 0.08%) -154k (- 0.04%) 437,210k 438,591k
Parse Time 1.82s (± 0.42%) 1.83s (± 0.60%) +0.01s (+ 0.44%) 1.80s 1.85s
Bind Time 0.55s (± 0.94%) 0.55s (± 0.60%) -0.00s (- 0.18%) 0.54s 0.56s
Check Time 12.74s (± 0.58%) 12.82s (± 0.85%) +0.09s (+ 0.68%) 12.66s 13.09s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.11s (± 0.54%) 15.21s (± 0.75%) +0.09s (+ 0.62%) 15.02s 15.49s
xstate - node (v12.1.0, x64)
Memory used 549,228k (± 0.01%) 552,334k (± 1.28%) +3,106k (+ 0.57%) 548,924k 580,863k
Parse Time 2.55s (± 0.47%) 2.55s (± 0.62%) +0.00s (+ 0.12%) 2.52s 2.59s
Bind Time 0.89s (± 0.66%) 0.90s (± 1.11%) +0.00s (+ 0.34%) 0.88s 0.93s
Check Time 1.47s (± 0.59%) 1.48s (± 0.82%) +0.01s (+ 0.61%) 1.46s 1.51s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 4.99s (± 0.36%) 5.00s (± 0.60%) +0.01s (+ 0.24%) 4.95s 5.09s
Angular - node (v14.15.1, x64)
Memory used 338,914k (± 0.01%) 338,915k (± 0.01%) +0k (+ 0.00%) 338,857k 338,956k
Parse Time 2.07s (± 0.76%) 2.06s (± 0.90%) -0.01s (- 0.29%) 2.03s 2.11s
Bind Time 0.80s (± 0.60%) 0.80s (± 0.56%) +0.00s (+ 0.13%) 0.79s 0.81s
Check Time 5.84s (± 0.45%) 5.87s (± 0.40%) +0.03s (+ 0.50%) 5.83s 5.93s
Emit Time 6.20s (± 0.56%) 6.19s (± 0.54%) -0.01s (- 0.23%) 6.13s 6.27s
Total Time 14.91s (± 0.35%) 14.91s (± 0.38%) +0.01s (+ 0.05%) 14.79s 15.05s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,883k (± 1.03%) 190,132k (± 0.01%) -1,752k (- 0.91%) 190,086k 190,186k
Parse Time 0.86s (± 1.25%) 0.86s (± 0.72%) -0.00s (- 0.23%) 0.84s 0.87s
Bind Time 0.49s (± 0.91%) 0.48s (± 0.75%) -0.00s (- 0.82%) 0.48s 0.49s
Check Time 6.74s (± 0.58%) 6.72s (± 0.93%) -0.02s (- 0.34%) 6.60s 6.86s
Emit Time 2.37s (± 0.91%) 2.37s (± 0.80%) -0.00s (- 0.13%) 2.32s 2.41s
Total Time 10.46s (± 0.57%) 10.43s (± 0.61%) -0.03s (- 0.30%) 10.29s 10.56s
Monaco - node (v14.15.1, x64)
Memory used 326,566k (± 0.01%) 326,557k (± 0.01%) -8k (- 0.00%) 326,503k 326,632k
Parse Time 1.59s (± 0.51%) 1.59s (± 0.84%) -0.01s (- 0.38%) 1.56s 1.62s
Bind Time 0.73s (± 1.06%) 0.72s (± 0.83%) -0.00s (- 0.55%) 0.72s 0.74s
Check Time 5.74s (± 0.47%) 5.69s (± 0.42%) -0.05s (- 0.92%) 5.63s 5.73s
Emit Time 3.33s (± 0.56%) 3.32s (± 0.43%) -0.01s (- 0.36%) 3.28s 3.35s
Total Time 11.39s (± 0.32%) 11.32s (± 0.29%) -0.08s (- 0.66%) 11.24s 11.38s
TFS - node (v14.15.1, x64)
Memory used 289,694k (± 0.00%) 289,693k (± 0.00%) -1k (- 0.00%) 289,660k 289,717k
Parse Time 1.30s (± 0.68%) 1.30s (± 0.58%) +0.00s (+ 0.08%) 1.28s 1.32s
Bind Time 0.79s (± 1.39%) 0.79s (± 0.75%) +0.00s (+ 0.51%) 0.78s 0.81s
Check Time 5.37s (± 0.45%) 5.37s (± 0.39%) -0.00s (- 0.02%) 5.32s 5.42s
Emit Time 3.55s (± 0.48%) 3.53s (± 0.97%) -0.02s (- 0.45%) 3.46s 3.62s
Total Time 11.01s (± 0.24%) 11.00s (± 0.40%) -0.01s (- 0.12%) 10.91s 11.10s
material-ui - node (v14.15.1, x64)
Memory used 436,551k (± 0.06%) 436,524k (± 0.06%) -27k (- 0.01%) 435,419k 436,674k
Parse Time 1.87s (± 0.64%) 1.88s (± 0.60%) +0.00s (+ 0.21%) 1.86s 1.91s
Bind Time 0.58s (± 0.63%) 0.58s (± 1.02%) -0.00s (- 0.17%) 0.57s 0.60s
Check Time 12.85s (± 0.72%) 12.99s (± 0.51%) +0.14s (+ 1.12%) 12.76s 13.12s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.31s (± 0.67%) 15.46s (± 0.42%) +0.15s (+ 0.97%) 15.23s 15.57s
xstate - node (v14.15.1, x64)
Memory used 546,976k (± 0.00%) 546,994k (± 0.00%) +18k (+ 0.00%) 546,966k 547,016k
Parse Time 2.62s (± 0.51%) 2.62s (± 0.53%) +0.01s (+ 0.23%) 2.59s 2.65s
Bind Time 0.97s (± 0.61%) 0.98s (± 1.06%) +0.01s (+ 0.72%) 0.96s 1.01s
Check Time 1.52s (± 0.66%) 1.54s (± 0.62%) +0.01s (+ 0.79%) 1.51s 1.55s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.19s (± 0.25%) 5.21s (± 0.39%) +0.03s (+ 0.50%) 5.15s 5.25s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory15 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 50759 10
Baseline main 10

TSServer

Comparison Report - main..50759
Metric main 50759 Delta Best Worst
Compiler-UnionsTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,411ms (± 0.55%) 1,408ms (± 0.64%) -2ms (- 0.16%) 1,384ms 1,427ms
Req 2 - geterr 4,110ms (± 0.58%) 4,122ms (± 0.75%) +12ms (+ 0.29%) 4,061ms 4,195ms
Req 3 - references 229ms (± 0.84%) 231ms (± 1.25%) +2ms (+ 0.74%) 225ms 238ms
Req 4 - navto 176ms (± 0.53%) 173ms (± 1.39%) -3ms (- 1.93%) 168ms 178ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 98ms (± 2.16%) 93ms (± 6.36%) 🟩-5ms (- 4.72%) 70ms 98ms
CompilerTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,505ms (± 0.46%) 1,497ms (± 0.44%) -9ms (- 0.57%) 1,478ms 1,508ms
Req 2 - geterr 2,267ms (± 0.54%) 2,258ms (± 0.52%) -9ms (- 0.38%) 2,229ms 2,292ms
Req 3 - references 244ms (± 0.54%) 244ms (± 0.58%) -1ms (- 0.20%) 241ms 247ms
Req 4 - navto 186ms (± 0.88%) 185ms (± 0.97%) -1ms (- 0.75%) 179ms 188ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 63ms (± 2.60%) 62ms (± 2.30%) -1ms (- 1.58%) 59ms 66ms
xstateTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 2,107ms (± 0.40%) 2,106ms (± 0.56%) -0ms (- 0.01%) 2,084ms 2,128ms
Req 2 - geterr 803ms (± 0.43%) 804ms (± 0.62%) +2ms (+ 0.19%) 788ms 814ms
Req 3 - references 98ms (± 1.35%) 98ms (± 1.26%) -1ms (- 0.51%) 95ms 100ms
Req 4 - navto 235ms (± 0.96%) 234ms (± 1.39%) -1ms (- 0.30%) 225ms 242ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 280ms (± 0.82%) 281ms (± 1.25%) +1ms (+ 0.18%) 270ms 286ms
Compiler-UnionsTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,404ms (± 0.70%) 1,404ms (± 0.53%) +0ms (+ 0.01%) 1,388ms 1,423ms
Req 2 - geterr 3,389ms (± 0.70%) 3,386ms (± 0.56%) -3ms (- 0.09%) 3,351ms 3,441ms
Req 3 - references 219ms (± 0.85%) 220ms (± 0.85%) +2ms (+ 0.69%) 216ms 223ms
Req 4 - navto 162ms (± 0.85%) 161ms (± 0.98%) -1ms (- 0.68%) 158ms 165ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 59ms (± 4.41%) 61ms (± 4.60%) +2ms (+ 3.72%) 55ms 66ms
CompilerTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,490ms (± 0.57%) 1,494ms (± 0.80%) +4ms (+ 0.27%) 1,470ms 1,526ms
Req 2 - geterr 2,164ms (± 0.57%) 2,174ms (± 0.60%) +10ms (+ 0.44%) 2,144ms 2,202ms
Req 3 - references 234ms (± 0.77%) 235ms (± 0.54%) +2ms (+ 0.64%) 233ms 238ms
Req 4 - navto 170ms (± 0.90%) 172ms (± 0.87%) +2ms (+ 0.88%) 168ms 174ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 62ms (± 3.67%) 61ms (± 3.19%) -0ms (- 0.65%) 58ms 67ms
xstateTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 2,044ms (± 0.49%) 2,048ms (± 0.58%) +4ms (+ 0.21%) 2,019ms 2,073ms
Req 2 - geterr 748ms (± 0.41%) 752ms (± 0.85%) +5ms (+ 0.66%) 742ms 773ms
Req 3 - references 68ms (± 1.01%) 67ms (± 0.44%) -0ms (- 0.59%) 67ms 68ms
Req 4 - navto 224ms (± 1.49%) 225ms (± 0.71%) +1ms (+ 0.49%) 221ms 228ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 275ms (± 1.01%) 275ms (± 1.13%) -0ms (- 0.11%) 267ms 280ms
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,451ms (± 0.47%) 1,448ms (± 0.40%) -3ms (- 0.23%) 1,428ms 1,458ms
Req 2 - geterr 3,526ms (± 0.45%) 3,512ms (± 0.75%) -14ms (- 0.40%) 3,444ms 3,566ms
Req 3 - references 230ms (± 0.61%) 231ms (± 0.51%) +1ms (+ 0.61%) 228ms 234ms
Req 4 - navto 171ms (± 0.66%) 171ms (± 0.69%) +0ms (+ 0.18%) 168ms 174ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 58ms (± 5.83%) 57ms (± 6.49%) -1ms (- 0.87%) 54ms 67ms
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,525ms (± 0.50%) 1,517ms (± 0.42%) -8ms (- 0.52%) 1,504ms 1,534ms
Req 2 - geterr 2,311ms (± 0.65%) 2,306ms (± 0.45%) -6ms (- 0.24%) 2,287ms 2,327ms
Req 3 - references 243ms (± 0.61%) 242ms (± 0.79%) -1ms (- 0.45%) 239ms 247ms
Req 4 - navto 179ms (± 0.82%) 178ms (± 0.54%) -1ms (- 0.50%) 177ms 181ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 55ms (± 1.33%) 55ms (± 1.06%) -0ms (- 0.18%) 53ms 56ms
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,146ms (± 0.81%) 2,156ms (± 0.48%) +10ms (+ 0.47%) 2,135ms 2,186ms
Req 2 - geterr 767ms (± 0.43%) 762ms (± 0.57%) -6ms (- 0.77%) 755ms 771ms
Req 3 - references 67ms (± 2.04%) 67ms (± 1.16%) -0ms (- 0.30%) 65ms 69ms
Req 4 - navto 229ms (± 0.49%) 228ms (± 0.93%) -1ms (- 0.26%) 223ms 232ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 283ms (± 4.34%) 277ms (± 0.82%) -6ms (- 2.19%) 273ms 282ms
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory15 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
  • Compiler-UnionsTSServer - node (v10.16.3, x64)
  • Compiler-UnionsTSServer - node (v12.1.0, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v10.16.3, x64)
  • CompilerTSServer - node (v12.1.0, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v10.16.3, x64)
  • xstateTSServer - node (v12.1.0, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 50759 10
Baseline main 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@andrewbranch andrewbranch changed the title Strip literal freshness when contextually typed by instantiable type … Strip literal freshness when contextually typed by instantiable type that has return mapper constraint inferences Sep 14, 2022
@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Milestone Bug PRs that fix a bug with a specific milestone labels Sep 14, 2022
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 16, 2022
@andrewbranch
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 19, 2022

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at 410d2f7. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 19, 2022

Hey @andrewbranch, 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/134599/artifacts?artifactName=tgz&fileId=CE3731705AA8C3AC9B46C3AE86878A60F56DEB628F3F489F7490DD61639AC3FE02&fileName=/typescript-4.9.0-insiders.20220919.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/pr-build@4.9.0-pr-50759-10".;

@andrewbranch
Copy link
Member Author

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 19, 2022

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 19, 2022

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 19, 2022

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..50759
Metric main 50759 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 363,385k (± 0.02%) 363,477k (± 0.02%) +91k (+ 0.03%) 363,366k 363,647k
Parse Time 2.09s (± 0.64%) 2.08s (± 0.46%) -0.00s (- 0.19%) 2.07s 2.11s
Bind Time 0.79s (± 0.75%) 0.79s (± 0.71%) -0.01s (- 0.76%) 0.78s 0.80s
Check Time 6.17s (± 0.32%) 6.18s (± 0.41%) +0.01s (+ 0.23%) 6.11s 6.23s
Emit Time 6.06s (± 0.91%) 6.06s (± 0.84%) -0.00s (- 0.07%) 5.92s 6.21s
Total Time 15.12s (± 0.35%) 15.12s (± 0.44%) 0.00s ( 0.00%) 14.96s 15.30s
Compiler-Unions - node (v10.16.3, x64)
Memory used 206,345k (± 0.05%) 205,947k (± 0.30%) -398k (- 0.19%) 203,493k 206,351k
Parse Time 0.83s (± 0.71%) 0.84s (± 0.48%) +0.01s (+ 0.60%) 0.83s 0.85s
Bind Time 0.47s (± 0.85%) 0.46s (± 1.07%) -0.00s (- 0.85%) 0.45s 0.47s
Check Time 8.40s (± 0.50%) 8.45s (± 0.54%) +0.05s (+ 0.58%) 8.31s 8.53s
Emit Time 2.46s (± 1.73%) 2.48s (± 1.78%) +0.02s (+ 0.73%) 2.42s 2.63s
Total Time 12.16s (± 0.44%) 12.23s (± 0.37%) +0.07s (+ 0.58%) 12.10s 12.33s
Monaco - node (v10.16.3, x64)
Memory used 344,772k (± 0.02%) 344,740k (± 0.02%) -32k (- 0.01%) 344,576k 344,851k
Parse Time 1.60s (± 0.81%) 1.59s (± 0.81%) -0.01s (- 0.63%) 1.56s 1.62s
Bind Time 0.70s (± 0.92%) 0.70s (± 1.46%) -0.00s (- 0.43%) 0.69s 0.73s
Check Time 6.19s (± 0.56%) 6.19s (± 0.52%) -0.00s (- 0.00%) 6.12s 6.27s
Emit Time 3.24s (± 0.93%) 3.21s (± 0.71%) -0.03s (- 0.86%) 3.16s 3.26s
Total Time 11.73s (± 0.52%) 11.68s (± 0.28%) -0.04s (- 0.36%) 11.64s 11.80s
TFS - node (v10.16.3, x64)
Memory used 306,029k (± 0.03%) 306,068k (± 0.03%) +39k (+ 0.01%) 305,890k 306,224k
Parse Time 1.28s (± 0.37%) 1.28s (± 0.41%) -0.00s (- 0.16%) 1.27s 1.29s
Bind Time 0.67s (± 0.83%) 0.67s (± 0.71%) +0.01s (+ 0.75%) 0.66s 0.68s
Check Time 5.48s (± 0.71%) 5.49s (± 0.41%) +0.01s (+ 0.18%) 5.45s 5.55s
Emit Time 3.42s (± 1.46%) 3.39s (± 1.03%) -0.03s (- 0.97%) 3.32s 3.49s
Total Time 10.85s (± 0.57%) 10.83s (± 0.41%) -0.02s (- 0.19%) 10.75s 10.93s
material-ui - node (v10.16.3, x64)
Memory used 459,168k (± 0.01%) 459,241k (± 0.01%) +72k (+ 0.02%) 459,174k 459,310k
Parse Time 1.82s (± 0.75%) 1.82s (± 0.66%) 0.00s ( 0.00%) 1.79s 1.84s
Bind Time 0.58s (± 2.25%) 0.58s (± 2.40%) -0.00s (- 0.34%) 0.55s 0.60s
Check Time 15.49s (± 0.26%) 15.48s (± 0.14%) -0.01s (- 0.08%) 15.41s 15.52s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 17.89s (± 0.24%) 17.87s (± 0.13%) -0.01s (- 0.08%) 17.81s 17.93s
xstate - node (v10.16.3, x64)
Memory used 590,670k (± 1.62%) 584,372k (± 0.02%) -6,298k (- 1.07%) 584,095k 584,724k
Parse Time 2.60s (± 0.25%) 2.61s (± 0.32%) +0.01s (+ 0.27%) 2.58s 2.62s
Bind Time 0.91s (± 0.66%) 0.91s (± 0.44%) +0.00s (+ 0.44%) 0.90s 0.92s
Check Time 1.59s (± 0.19%) 1.60s (± 0.52%) +0.00s (+ 0.25%) 1.58s 1.62s
Emit Time 0.07s (± 3.14%) 0.07s (± 4.13%) +0.00s (+ 1.41%) 0.07s 0.08s
Total Time 5.16s (± 0.21%) 5.18s (± 0.24%) +0.02s (+ 0.33%) 5.16s 5.21s
Angular - node (v12.1.0, x64)
Memory used 340,740k (± 0.10%) 340,821k (± 0.06%) +81k (+ 0.02%) 340,075k 341,066k
Parse Time 2.08s (± 0.62%) 2.09s (± 0.86%) +0.01s (+ 0.53%) 2.06s 2.14s
Bind Time 0.78s (± 0.64%) 0.77s (± 0.61%) -0.01s (- 0.65%) 0.76s 0.78s
Check Time 5.85s (± 0.89%) 5.84s (± 0.40%) -0.01s (- 0.14%) 5.78s 5.90s
Emit Time 6.33s (± 0.79%) 6.26s (± 0.97%) -0.07s (- 1.07%) 6.16s 6.42s
Total Time 15.04s (± 0.68%) 14.97s (± 0.47%) -0.07s (- 0.46%) 14.78s 15.12s
Compiler-Unions - node (v12.1.0, x64)
Memory used 193,708k (± 0.29%) 193,518k (± 0.30%) -190k (- 0.10%) 191,294k 194,033k
Parse Time 0.83s (± 0.87%) 0.83s (± 0.57%) -0.00s (- 0.24%) 0.82s 0.84s
Bind Time 0.48s (± 1.00%) 0.47s (± 0.72%) -0.00s (- 0.84%) 0.47s 0.48s
Check Time 6.71s (± 0.67%) 6.72s (± 0.42%) +0.00s (+ 0.07%) 6.64s 6.77s
Emit Time 2.47s (± 0.92%) 2.45s (± 0.87%) -0.02s (- 0.85%) 2.42s 2.51s
Total Time 10.49s (± 0.42%) 10.46s (± 0.33%) -0.03s (- 0.26%) 10.37s 10.52s
Monaco - node (v12.1.0, x64)
Memory used 327,690k (± 0.02%) 327,730k (± 0.02%) +40k (+ 0.01%) 327,590k 327,872k
Parse Time 1.58s (± 0.88%) 1.58s (± 0.56%) -0.00s (- 0.13%) 1.56s 1.60s
Bind Time 0.70s (± 0.68%) 0.70s (± 0.72%) -0.00s (- 0.29%) 0.69s 0.71s
Check Time 5.81s (± 0.46%) 5.83s (± 0.67%) +0.02s (+ 0.34%) 5.73s 5.92s
Emit Time 3.30s (± 0.68%) 3.32s (± 1.01%) +0.02s (+ 0.54%) 3.25s 3.41s
Total Time 11.39s (± 0.40%) 11.42s (± 0.64%) +0.03s (+ 0.29%) 11.24s 11.61s
TFS - node (v12.1.0, x64)
Memory used 290,648k (± 0.03%) 290,582k (± 0.06%) -66k (- 0.02%) 289,907k 290,730k
Parse Time 1.29s (± 0.85%) 1.28s (± 0.74%) -0.00s (- 0.39%) 1.27s 1.30s
Bind Time 0.67s (± 1.40%) 0.68s (± 1.12%) +0.00s (+ 0.45%) 0.66s 0.69s
Check Time 5.40s (± 0.33%) 5.38s (± 0.46%) -0.02s (- 0.31%) 5.34s 5.46s
Emit Time 3.52s (± 0.70%) 3.50s (± 0.72%) -0.02s (- 0.68%) 3.44s 3.55s
Total Time 10.88s (± 0.37%) 10.84s (± 0.34%) -0.05s (- 0.44%) 10.76s 10.93s
material-ui - node (v12.1.0, x64)
Memory used 438,481k (± 0.01%) 438,437k (± 0.01%) -44k (- 0.01%) 438,328k 438,545k
Parse Time 1.83s (± 0.68%) 1.82s (± 0.52%) -0.01s (- 0.55%) 1.81s 1.85s
Bind Time 0.55s (± 1.01%) 0.55s (± 0.81%) -0.00s (- 0.72%) 0.54s 0.56s
Check Time 12.87s (± 0.73%) 12.75s (± 0.65%) -0.12s (- 0.96%) 12.57s 12.98s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.26s (± 0.63%) 15.12s (± 0.56%) -0.14s (- 0.91%) 14.93s 15.35s
xstate - node (v12.1.0, x64)
Memory used 549,341k (± 0.02%) 549,327k (± 0.02%) -14k (- 0.00%) 549,100k 549,581k
Parse Time 2.55s (± 0.34%) 2.54s (± 0.35%) -0.01s (- 0.47%) 2.52s 2.56s
Bind Time 0.89s (± 0.79%) 0.89s (± 0.42%) -0.00s (- 0.45%) 0.88s 0.89s
Check Time 1.47s (± 0.33%) 1.48s (± 0.44%) +0.01s (+ 0.54%) 1.47s 1.50s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 4.99s (± 0.23%) 4.98s (± 0.26%) -0.01s (- 0.20%) 4.95s 5.01s
Angular - node (v14.15.1, x64)
Memory used 338,956k (± 0.01%) 338,993k (± 0.01%) +37k (+ 0.01%) 338,951k 339,043k
Parse Time 2.05s (± 0.67%) 2.06s (± 0.69%) +0.00s (+ 0.19%) 2.03s 2.09s
Bind Time 0.79s (± 0.43%) 0.80s (± 0.81%) +0.01s (+ 0.63%) 0.78s 0.81s
Check Time 5.86s (± 0.65%) 5.84s (± 0.39%) -0.01s (- 0.24%) 5.78s 5.89s
Emit Time 6.23s (± 0.52%) 6.22s (± 0.32%) -0.00s (- 0.05%) 6.19s 6.28s
Total Time 14.93s (± 0.44%) 14.92s (± 0.23%) -0.01s (- 0.07%) 14.84s 14.98s
Compiler-Unions - node (v14.15.1, x64)
Memory used 189,996k (± 0.16%) 190,211k (± 0.01%) +215k (+ 0.11%) 190,146k 190,267k
Parse Time 0.86s (± 0.69%) 0.85s (± 0.70%) -0.00s (- 0.23%) 0.84s 0.87s
Bind Time 0.49s (± 0.98%) 0.48s (± 0.75%) -0.00s (- 0.62%) 0.48s 0.49s
Check Time 6.78s (± 0.58%) 6.72s (± 0.51%) -0.06s (- 0.86%) 6.65s 6.79s
Emit Time 2.42s (± 1.21%) 2.39s (± 0.60%) -0.03s (- 1.03%) 2.36s 2.42s
Total Time 10.54s (± 0.52%) 10.45s (± 0.48%) -0.09s (- 0.84%) 10.34s 10.55s
Monaco - node (v14.15.1, x64)
Memory used 326,540k (± 0.01%) 326,525k (± 0.01%) -16k (- 0.00%) 326,478k 326,551k
Parse Time 1.57s (± 0.48%) 1.59s (± 0.72%) +0.01s (+ 0.89%) 1.57s 1.62s
Bind Time 0.72s (± 0.66%) 0.72s (± 0.65%) -0.00s (- 0.41%) 0.71s 0.73s
Check Time 5.71s (± 0.48%) 5.70s (± 0.38%) -0.01s (- 0.21%) 5.65s 5.75s
Emit Time 3.37s (± 0.58%) 3.37s (± 0.67%) +0.00s (+ 0.06%) 3.33s 3.43s
Total Time 11.38s (± 0.20%) 11.39s (± 0.35%) +0.00s (+ 0.02%) 11.31s 11.50s
TFS - node (v14.15.1, x64)
Memory used 289,652k (± 0.01%) 289,683k (± 0.01%) +31k (+ 0.01%) 289,619k 289,748k
Parse Time 1.30s (± 1.08%) 1.29s (± 0.43%) -0.01s (- 1.08%) 1.28s 1.30s
Bind Time 0.80s (± 0.83%) 0.79s (± 0.62%) -0.01s (- 0.75%) 0.79s 0.81s
Check Time 5.38s (± 0.46%) 5.38s (± 0.38%) -0.01s (- 0.13%) 5.33s 5.42s
Emit Time 3.61s (± 0.46%) 3.61s (± 0.70%) +0.00s (+ 0.11%) 3.57s 3.67s
Total Time 11.10s (± 0.36%) 11.07s (± 0.15%) -0.02s (- 0.21%) 11.03s 11.11s
material-ui - node (v14.15.1, x64)
Memory used 436,666k (± 0.00%) 436,667k (± 0.00%) +1k (+ 0.00%) 436,642k 436,692k
Parse Time 1.88s (± 0.68%) 1.87s (± 0.61%) -0.01s (- 0.53%) 1.85s 1.90s
Bind Time 0.59s (± 1.29%) 0.58s (± 0.81%) -0.01s (- 1.02%) 0.57s 0.59s
Check Time 12.86s (± 0.46%) 12.79s (± 0.30%) -0.06s (- 0.48%) 12.73s 12.89s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.32s (± 0.45%) 15.24s (± 0.29%) -0.08s (- 0.52%) 15.16s 15.35s
xstate - node (v14.15.1, x64)
Memory used 547,046k (± 0.00%) 547,047k (± 0.00%) +1k (+ 0.00%) 547,010k 547,082k
Parse Time 2.63s (± 0.56%) 2.61s (± 0.46%) -0.02s (- 0.87%) 2.58s 2.63s
Bind Time 0.99s (± 1.23%) 0.97s (± 1.13%) -0.01s (- 1.22%) 0.96s 1.01s
Check Time 1.52s (± 0.46%) 1.52s (± 0.29%) -0.00s (- 0.20%) 1.51s 1.53s
Emit Time 0.07s (± 3.14%) 0.07s (± 0.00%) -0.00s (- 1.41%) 0.07s 0.07s
Total Time 5.21s (± 0.45%) 5.18s (± 0.33%) -0.03s (- 0.61%) 5.15s 5.22s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory15 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 50759 10
Baseline main 10

TSServer

Comparison Report - main..50759
Metric main 50759 Delta Best Worst
Compiler-UnionsTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,404ms (± 0.48%) 1,396ms (± 0.51%) -9ms (- 0.63%) 1,381ms 1,413ms
Req 2 - geterr 4,076ms (± 0.68%) 4,061ms (± 0.54%) -15ms (- 0.36%) 4,021ms 4,109ms
Req 3 - references 230ms (± 1.06%) 229ms (± 1.58%) -0ms (- 0.09%) 222ms 239ms
Req 4 - navto 172ms (± 1.28%) 170ms (± 1.14%) -1ms (- 0.76%) 165ms 175ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 92ms (± 2.73%) 94ms (± 1.93%) +2ms (+ 2.39%) 90ms 97ms
CompilerTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 1,491ms (± 0.48%) 1,495ms (± 0.43%) +4ms (+ 0.28%) 1,482ms 1,510ms
Req 2 - geterr 2,258ms (± 0.37%) 2,251ms (± 0.54%) -7ms (- 0.31%) 2,236ms 2,295ms
Req 3 - references 243ms (± 0.54%) 243ms (± 0.80%) 0ms ( 0.00%) 240ms 246ms
Req 4 - navto 182ms (± 0.56%) 184ms (± 0.75%) +2ms (+ 1.10%) 181ms 187ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 61ms (± 1.65%) 61ms (± 3.30%) +1ms (+ 1.15%) 58ms 68ms
xstateTSServer - node (v10.16.3, x64)
Req 1 - updateOpen 2,083ms (± 0.49%) 2,083ms (± 0.34%) -0ms (- 0.02%) 2,066ms 2,097ms
Req 2 - geterr 797ms (± 0.47%) 795ms (± 0.70%) -2ms (- 0.23%) 785ms 810ms
Req 3 - references 96ms (± 1.48%) 96ms (± 2.07%) +0ms (+ 0.21%) 92ms 103ms
Req 4 - navto 231ms (± 0.90%) 232ms (± 1.23%) +1ms (+ 0.56%) 227ms 238ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 280ms (± 1.07%) 279ms (± 0.95%) -1ms (- 0.46%) 275ms 285ms
Compiler-UnionsTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,421ms (± 0.75%) 1,418ms (± 1.08%) -3ms (- 0.21%) 1,382ms 1,443ms
Req 2 - geterr 3,408ms (± 0.40%) 3,368ms (± 0.44%) -39ms (- 1.15%) 3,332ms 3,396ms
Req 3 - references 223ms (± 1.61%) 220ms (± 0.54%) -2ms (- 1.08%) 218ms 223ms
Req 4 - navto 161ms (± 1.06%) 158ms (± 0.94%) -3ms (- 1.55%) 155ms 162ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 61ms (± 3.55%) 61ms (± 4.89%) -0ms (- 0.49%) 55ms 67ms
CompilerTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 1,512ms (± 0.55%) 1,499ms (± 0.45%) -13ms (- 0.87%) 1,483ms 1,513ms
Req 2 - geterr 2,181ms (± 0.55%) 2,166ms (± 0.46%) -15ms (- 0.67%) 2,139ms 2,186ms
Req 3 - references 236ms (± 0.51%) 234ms (± 0.78%) -3ms (- 1.06%) 231ms 237ms
Req 4 - navto 171ms (± 1.03%) 170ms (± 0.82%) -1ms (- 0.35%) 167ms 173ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 63ms (± 2.73%) 61ms (± 2.86%) 🟩-2ms (- 3.47%) 57ms 64ms
xstateTSServer - node (v12.1.0, x64)
Req 1 - updateOpen 2,053ms (± 0.64%) 2,040ms (± 0.40%) -13ms (- 0.61%) 2,016ms 2,055ms
Req 2 - geterr 752ms (± 0.94%) 749ms (± 0.53%) -3ms (- 0.43%) 738ms 756ms
Req 3 - references 68ms (± 1.45%) 67ms (± 1.79%) -0ms (- 0.59%) 64ms 70ms
Req 4 - navto 225ms (± 0.71%) 223ms (± 1.89%) -2ms (- 0.89%) 211ms 229ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 276ms (± 0.29%) 275ms (± 1.54%) -1ms (- 0.25%) 262ms 281ms
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,453ms (± 0.56%) 1,440ms (± 0.49%) -12ms (- 0.85%) 1,427ms 1,455ms
Req 2 - geterr 3,505ms (± 0.58%) 3,515ms (± 0.67%) +10ms (+ 0.29%) 3,479ms 3,570ms
Req 3 - references 230ms (± 0.66%) 230ms (± 0.60%) -0ms (- 0.13%) 228ms 234ms
Req 4 - navto 170ms (± 0.65%) 169ms (± 0.81%) -1ms (- 0.59%) 167ms 173ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 55ms (± 2.82%) 58ms (± 6.28%) +2ms (+ 3.98%) 54ms 68ms
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 1,521ms (± 0.32%) 1,516ms (± 0.62%) -6ms (- 0.36%) 1,499ms 1,536ms
Req 2 - geterr 2,299ms (± 0.20%) 2,305ms (± 0.30%) +6ms (+ 0.25%) 2,289ms 2,323ms
Req 3 - references 242ms (± 0.75%) 241ms (± 0.37%) -0ms (- 0.12%) 240ms 244ms
Req 4 - navto 177ms (± 0.55%) 178ms (± 0.49%) +1ms (+ 0.40%) 176ms 180ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 55ms (± 2.00%) 55ms (± 0.95%) -0ms (- 0.18%) 54ms 56ms
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,155ms (± 0.27%) 2,143ms (± 0.47%) -12ms (- 0.56%) 2,118ms 2,168ms
Req 2 - geterr 769ms (± 0.59%) 764ms (± 0.44%) -6ms (- 0.73%) 758ms 774ms
Req 3 - references 68ms (± 1.70%) 67ms (± 1.16%) -1ms (- 1.18%) 65ms 69ms
Req 4 - navto 229ms (± 0.53%) 230ms (± 1.75%) +1ms (+ 0.26%) 223ms 243ms
Req 5 - completionInfo count 3,301 (± 0.00%) 3,301 (± 0.00%) 0 ( 0.00%) 3,301 3,301
Req 5 - completionInfo 289ms (± 4.12%) 280ms (± 1.62%) 🟩-10ms (- 3.32%) 271ms 290ms
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory15 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
  • Compiler-UnionsTSServer - node (v10.16.3, x64)
  • Compiler-UnionsTSServer - node (v12.1.0, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v10.16.3, x64)
  • CompilerTSServer - node (v12.1.0, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v10.16.3, x64)
  • xstateTSServer - node (v12.1.0, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 50759 10
Baseline main 10

Developer Information:

Download Benchmark

@ahejlsberg
Copy link
Member

Hmm, I'm not sure about this one. The thing that strikes me is the convoluted use of generics in asLiteral. It constrains T to an array type, when really all the function cares about is the element type, as demonstrated by T[number] in the return type. When I simplify it to make the type variable as specific as possible, it all works just fine:

declare function asLiteral<T extends string | boolean | number>(...literals: T[]): (val: unknown) => val is T;

I'm not sure I think we need to do anything other than recommend this rewrite.

@andrewbranch
Copy link
Member Author

@ahejlsberg what about the other issue this fixes? #50787

type Model = { s: string; b: boolean }
let pick: <Keys extends keyof Model>(properties: readonly Keys[]) => Pick<Model, Keys>
let transform: <T>(obj: T) => T

const result1 = transform(pick(["s"]))
// 4.7: Pick<Model, "s">
// 4.8: Pick<Model, keyof Model>

@ahejlsberg
Copy link
Member

@andrewbranch The root cause of #50787 is that we consider the apparent type of an unconstrained type parameter to be {} in non-strictNullChecks mode. This then gets us in trouble when we use the return type mapper to infer from T to Pick<Model, Keys> because T turns into {} causing us to infer never for Keys. It works in strictNullChecks mode because the apparent type of T is unknown from which we make no inferences.

I'd suggest changing these lines in inferTypes

                    source = getReducedType(source);
                    if (!(priority & InferencePriority.NoConstraints && source.flags & (TypeFlags.Intersection | TypeFlags.Instantiable))) {
                        const apparentSource = getApparentType(source);

to this

                    source = getReducedType(source);
                    if (!(priority & InferencePriority.NoConstraints && source.flags & (TypeFlags.Intersection | TypeFlags.Instantiable)) &&
                        !(source.flags & TypeFlags.Instantiable && !getBaseConstraintOfType(source))) {
                        const apparentSource = getApparentType(source);

i.e. skip making inferences where there is no constraint, regardless of mode. It fixes the issue with no changes in the test suite. But of course it may affect some of the extended test suites.

@andrewbranch
Copy link
Member Author

It’s not clear though why specifying a very wide constraint like unknown or {} should behave differently than not specifying a constraint. In 4.7, and in this PR, this form also produces Pick<Model, "s">:

type Model = { s: string; b: boolean }
declare let pick: <Keys extends keyof Model>(properties: readonly Keys[]) => Pick<Model, Keys>
declare let transform2: <T extends {}>(obj: T) => T
const result2 = transform2(pick(["s"]))
// 4.7:              Pick<Model, "s">
// 4.8:              Pick<Model, keyof Model>
// This PR:          Pick<Model, "s">
// Suggested change: Pick<Model, keyof Model>

I don’t see a good reason why extends {} (a reasonable constraint to add for T!) should compromise the narrow inference for Keys.

@Andarist
Copy link
Contributor

This would also fix #56912 . So in that sense, it's competing with #56953 - which also fixes one of the issues referenced by this PR (but it doesn't fix the other one).

@andrewbranch andrewbranch deleted the bug/50635 branch August 5, 2024 21:14
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
Status: Done
4 participants