Skip to content

Fix for relating covered discriminants in unions - #39393

Merged
Ron Buckton (rbuckton) merged 1 commit into
masterfrom
fix39357
Jul 7, 2020
Merged

Fix for relating covered discriminants in unions#39393
Ron Buckton (rbuckton) merged 1 commit into
masterfrom
fix39357

Conversation

@rbuckton

@rbucktonRon Buckton (rbuckton) commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

In #30779 we added the ability to relate a source type to a target when the target is a discriminated union and the source is covered by the target. This did not work when the target was a union of tuple types as the relationship check would fail when comparing the synthesized index types for each tuple in indexTypesRelatedTo. This was further complicated by the fact that the new variadic tuple type logic added to propertiesRelatedTo fails to exclude relationship checks for non-variable elements whose indices are included in the excludedProperties map.

This PR does two things to address these issues:

  • Adds discriminant exclusion into the tuple-specific branch in propertiesRelatedTo so that it aligns with the existing, non-tuple-specific logic.
  • Skips the indexTypesRelatedTo check when both the source type and the target type are tuples, as the index type check should be sufficiently covered by the tuple-specific branch in propertiesRelatedTo.

Alternatively, rather than skipping the indexTypesRelatedTo check, we could synthesize a copy of the source and target tuple types with the excluded discriminants erased to never so that they are excluded from the index type. That would result in the allocation of types purely to accommodate indexTypesRelatedTo, which would then be subsequently discarded. This seems like an unnecessary cost, as propertiesRelatedTo sufficiently covers the numeric index type case.

Fixes#39357
Fixes#34967

@rbuckton

Copy link
Copy Markdown
ContributorAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at 8eba362. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at 8eba362. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at 8eba362. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jul 2, 2020

Copy link
Copy Markdown
Contributor

Heya Ron Buckton (@rbuckton), I've started to run the parallelized community code test suite on this PR at 8eba362. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

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

@typescript-bot

Copy link
Copy Markdown
Contributor

Ron Buckton (@rbuckton)
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..39393

Metricmaster39393DeltaBestWorst
Angular - node (v10.16.3, x64)
Memory used344,003k (± 0.02%)343,525k (± 0.03%)-478k (- 0.14%)343,310k343,841k
Parse Time2.00s (± 0.58%)2.01s (± 0.67%)+0.00s (+ 0.15%)1.98s2.03s
Bind Time0.82s (± 0.41%)0.82s (± 0.60%)-0.00s (- 0.49%)0.81s0.83s
Check Time4.72s (± 0.32%)4.70s (± 0.51%)-0.01s (- 0.30%)4.65s4.74s
Emit Time5.17s (± 0.39%)5.15s (± 0.70%)-0.02s (- 0.39%)5.10s5.26s
Total Time12.71s (± 0.24%)12.68s (± 0.47%)-0.04s (- 0.28%)12.55s12.86s
Monaco - node (v10.16.3, x64)
Memory used339,106k (± 0.02%)339,046k (± 0.02%)-60k (- 0.02%)338,950k339,244k
Parse Time1.58s (± 0.64%)1.59s (± 0.50%)+0.01s (+ 0.83%)1.57s1.61s
Bind Time0.71s (± 0.63%)0.71s (± 0.67%)-0.01s (- 0.70%)0.70s0.72s
Check Time4.86s (± 0.50%)4.86s (± 0.56%)+0.01s (+ 0.16%)4.81s4.92s
Emit Time2.77s (± 0.66%)2.74s (± 0.41%)-0.03s (- 1.05%)2.71s2.76s
Total Time9.91s (± 0.40%)9.90s (± 0.39%)-0.02s (- 0.15%)9.81s9.98s
TFS - node (v10.16.3, x64)
Memory used301,981k (± 0.03%)302,036k (± 0.03%)+55k (+ 0.02%)301,930k302,266k
Parse Time1.21s (± 0.75%)1.21s (± 0.70%)0.00s ( 0.00%)1.19s1.22s
Bind Time0.66s (± 1.28%)0.67s (± 1.12%)+0.01s (+ 0.91%)0.64s0.68s
Check Time4.40s (± 0.53%)4.36s (± 0.52%)-0.04s (- 0.84%)4.32s4.42s
Emit Time2.88s (± 1.22%)2.88s (± 0.78%)+0.00s (+ 0.03%)2.83s2.94s
Total Time9.14s (± 0.64%)9.11s (± 0.36%)-0.03s (- 0.32%)9.03s9.20s
material-ui - node (v10.16.3, x64)
Memory used459,384k (± 0.01%)459,141k (± 0.01%)-244k (- 0.05%)458,995k459,263k
Parse Time2.05s (± 0.52%)2.04s (± 0.25%)-0.00s (- 0.20%)2.03s2.05s
Bind Time0.66s (± 1.28%)0.65s (± 1.08%)-0.01s (- 1.21%)0.64s0.67s
Check Time12.80s (± 0.48%)12.84s (± 0.80%)+0.04s (+ 0.27%)12.68s13.16s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time15.50s (± 0.44%)15.53s (± 0.67%)+0.03s (+ 0.17%)15.37s15.87s
Angular - node (v12.1.0, x64)
Memory used321,096k (± 0.03%)320,726k (± 0.03%)-370k (- 0.12%)320,519k320,983k
Parse Time1.99s (± 0.68%)1.98s (± 0.75%)-0.01s (- 0.40%)1.94s2.00s
Bind Time0.80s (± 0.85%)0.80s (± 0.59%)-0.00s (- 0.62%)0.79s0.81s
Check Time4.60s (± 0.47%)4.60s (± 0.49%)-0.00s (- 0.04%)4.55s4.66s
Emit Time5.34s (± 0.56%)5.33s (± 0.34%)-0.01s (- 0.13%)5.30s5.37s
Total Time12.73s (± 0.37%)12.71s (± 0.27%)-0.02s (- 0.20%)12.64s12.79s
Monaco - node (v12.1.0, x64)
Memory used321,518k (± 0.02%)321,507k (± 0.02%)-11k (- 0.00%)321,422k321,645k
Parse Time1.55s (± 0.83%)1.54s (± 0.44%)-0.01s (- 0.58%)1.54s1.57s
Bind Time0.69s (± 0.84%)0.68s (± 0.70%)-0.00s (- 0.58%)0.67s0.69s
Check Time4.65s (± 0.54%)4.63s (± 0.43%)-0.01s (- 0.30%)4.60s4.69s
Emit Time2.80s (± 0.61%)2.80s (± 0.73%)+0.00s (+ 0.11%)2.75s2.83s
Total Time9.68s (± 0.38%)9.66s (± 0.36%)-0.02s (- 0.21%)9.60s9.74s
TFS - node (v12.1.0, x64)
Memory used286,487k (± 0.02%)286,475k (± 0.02%)-11k (- 0.00%)286,312k286,583k
Parse Time1.23s (± 0.61%)1.24s (± 1.41%)+0.01s (+ 0.90%)1.21s1.29s
Bind Time0.64s (± 1.20%)0.64s (± 1.14%)+0.00s (+ 0.47%)0.63s0.66s
Check Time4.26s (± 0.51%)4.26s (± 0.64%)-0.00s (- 0.07%)4.17s4.31s
Emit Time2.91s (± 0.96%)2.93s (± 0.74%)+0.02s (+ 0.83%)2.89s2.99s
Total Time9.04s (± 0.45%)9.07s (± 0.46%)+0.03s (+ 0.34%)8.97s9.17s
material-ui - node (v12.1.0, x64)
Memory used437,699k (± 0.05%)437,426k (± 0.05%)-273k (- 0.06%)436,516k437,639k
Parse Time2.01s (± 0.47%)2.02s (± 0.49%)+0.01s (+ 0.35%)2.00s2.04s
Bind Time0.63s (± 1.18%)0.63s (± 1.05%)0.00s ( 0.00%)0.62s0.65s
Check Time11.54s (± 0.86%)11.57s (± 1.06%)+0.03s (+ 0.24%)11.35s11.91s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time14.18s (± 0.70%)14.22s (± 0.87%)+0.04s (+ 0.25%)13.98s14.56s
Angular - node (v8.9.0, x64)
Memory used340,422k (± 0.02%)340,050k (± 0.02%)-371k (- 0.11%)339,923k340,245k
Parse Time2.54s (± 0.44%)2.52s (± 0.27%)-0.02s (- 0.71%)2.50s2.53s
Bind Time0.85s (± 0.89%)0.85s (± 0.79%)-0.01s (- 0.94%)0.83s0.86s
Check Time5.33s (± 0.55%)5.35s (± 0.66%)+0.02s (+ 0.36%)5.29s5.46s
Emit Time5.98s (± 0.88%)5.88s (± 1.67%)-0.09s (- 1.56%)5.67s6.06s
Total Time14.70s (± 0.30%)14.60s (± 0.81%)-0.10s (- 0.67%)14.36s14.80s
Monaco - node (v8.9.0, x64)
Memory used340,467k (± 0.01%)340,461k (± 0.01%)-7k (- 0.00%)340,406k340,522k
Parse Time1.87s (± 0.47%)1.87s (± 0.66%)-0.00s (- 0.16%)1.85s1.91s
Bind Time0.88s (± 0.45%)0.88s (± 0.45%)0.00s ( 0.00%)0.87s0.89s
Check Time5.36s (± 0.58%)5.38s (± 0.60%)+0.02s (+ 0.37%)5.32s5.46s
Emit Time3.22s (± 0.41%)3.22s (± 0.75%)+0.00s (+ 0.12%)3.19s3.29s
Total Time11.33s (± 0.43%)11.35s (± 0.47%)+0.02s (+ 0.16%)11.26s11.52s
TFS - node (v8.9.0, x64)
Memory used303,763k (± 0.01%)303,812k (± 0.02%)+49k (+ 0.02%)303,635k303,956k
Parse Time1.55s (± 0.92%)1.55s (± 0.32%)-0.00s (- 0.06%)1.53s1.55s
Bind Time0.67s (± 0.67%)0.67s (± 1.14%)-0.00s (- 0.45%)0.65s0.68s
Check Time4.99s (± 1.47%)5.02s (± 1.64%)+0.03s (+ 0.64%)4.84s5.16s
Emit Time3.04s (± 3.30%)3.03s (± 3.07%)-0.01s (- 0.30%)2.88s3.20s
Total Time10.24s (± 0.35%)10.26s (± 0.53%)+0.02s (+ 0.21%)10.12s10.37s
material-ui - node (v8.9.0, x64)
Memory used463,609k (± 0.01%)463,357k (± 0.01%)-252k (- 0.05%)463,264k463,495k
Parse Time2.39s (± 0.73%)2.38s (± 0.22%)-0.01s (- 0.42%)2.37s2.39s
Bind Time0.78s (± 0.98%)0.77s (± 0.88%)-0.00s (- 0.26%)0.76s0.79s
Check Time17.11s (± 1.10%)17.23s (± 0.50%)+0.12s (+ 0.70%)17.07s17.51s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time20.28s (± 0.99%)20.38s (± 0.45%)+0.11s (+ 0.54%)20.22s20.69s
Angular - node (v8.9.0, x86)
Memory used195,298k (± 0.03%)195,097k (± 0.02%)-201k (- 0.10%)194,989k195,173k
Parse Time2.46s (± 0.51%)2.44s (± 0.40%)-0.01s (- 0.61%)2.41s2.46s
Bind Time0.99s (± 0.75%)0.98s (± 0.76%)-0.01s (- 0.71%)0.97s1.00s
Check Time4.81s (± 0.44%)4.79s (± 0.57%)-0.01s (- 0.31%)4.75s4.85s
Emit Time5.91s (± 1.20%)5.92s (± 1.23%)+0.02s (+ 0.25%)5.76s6.09s
Total Time14.17s (± 0.45%)14.15s (± 0.55%)-0.02s (- 0.13%)14.04s14.38s
Monaco - node (v8.9.0, x86)
Memory used193,429k (± 0.02%)193,456k (± 0.02%)+28k (+ 0.01%)193,356k193,532k
Parse Time1.90s (± 0.69%)1.91s (± 0.80%)+0.01s (+ 0.26%)1.88s1.94s
Bind Time0.70s (± 0.96%)0.70s (± 0.95%)+0.00s (+ 0.43%)0.69s0.72s
Check Time5.48s (± 0.42%)5.43s (± 1.33%)-0.04s (- 0.82%)5.18s5.57s
Emit Time2.67s (± 0.89%)2.71s (± 3.00%)+0.04s (+ 1.42%)2.64s3.03s
Total Time10.74s (± 0.30%)10.75s (± 0.47%)+0.00s (+ 0.05%)10.68s10.87s
TFS - node (v8.9.0, x86)
Memory used173,700k (± 0.02%)173,689k (± 0.02%)-11k (- 0.01%)173,636k173,793k
Parse Time1.58s (± 0.87%)1.60s (± 1.18%)+0.02s (+ 1.01%)1.56s1.65s
Bind Time0.63s (± 0.94%)0.64s (± 0.75%)+0.00s (+ 0.47%)0.63s0.65s
Check Time4.60s (± 0.38%)4.64s (± 0.89%)+0.04s (+ 0.87%)4.57s4.76s
Emit Time2.79s (± 0.85%)2.78s (± 0.67%)-0.01s (- 0.18%)2.74s2.83s
Total Time9.61s (± 0.34%)9.66s (± 0.50%)+0.05s (+ 0.53%)9.57s9.81s
material-ui - node (v8.9.0, x86)
Memory used262,557k (± 0.02%)262,394k (± 0.02%)-162k (- 0.06%)262,243k262,502k
Parse Time2.44s (± 0.88%)2.45s (± 0.56%)+0.01s (+ 0.49%)2.42s2.48s
Bind Time0.67s (± 0.71%)0.67s (± 1.05%)+0.00s (+ 0.30%)0.66s0.69s
Check Time15.62s (± 0.76%)15.77s (± 0.71%)+0.15s (+ 0.98%)15.58s16.00s
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)0.00s ( NaN%)0.00s0.00s
Total Time18.72s (± 0.60%)18.89s (± 0.62%)+0.17s (+ 0.89%)18.69s19.14s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
BenchmarkNameIterations
Current3939310
Baselinemaster10

@rbuckton

Copy link
Copy Markdown
ContributorAuthor

I noticed some failures in the DT test run. I'm trying to determine if these are existing errors or are due to this change.

@rbuckton

Copy link
Copy Markdown
ContributorAuthor

It looks like the DT failures are issues in DT:

@rbuckton
Ron Buckton (rbuckton) merged commit b100680 into masterJul 7, 2020
@rbuckton
Ron Buckton (rbuckton) deleted the fix39357 branch July 7, 2020 20:12
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Equivalence between tuple containing union type and union type of tuples Not assignable Type

3 participants

@rbuckton@typescript-bot@weswigham