Skip to content

Check if switch statements are exhaustive when their expressions is generic with a literal type constraint - #60644

Merged
Gabriela Araujo Britto (gabritto) merged 1 commit into
microsoft:mainfrom
Andarist:fix/exhaustive-switch-on-exhaustive-generic-literals
Dec 2, 2024
Merged

Check if switch statements are exhaustive when their expressions is generic with a literal type constraint#60644
Gabriela Araujo Britto (gabritto) merged 1 commit into
microsoft:mainfrom
Andarist:fix/exhaustive-switch-on-exhaustive-generic-literals

Conversation

@Andarist

@AndaristMateusz Burzyński (Andarist) commented Nov 30, 2024

Copy link
Copy Markdown
Contributor

cc Gabriela Araujo Britto (@gabritto) since it's somewhat related to #56941

fixes#60658

@typescript-botTypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 30, 2024
@typescript-bot

Copy link
Copy Markdown
Contributor

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

@jfet97

Copy link
Copy Markdown
Contributor

That "person" case is suspiciously familiar :P
Btw thanks :D

@Jontii

Copy link
Copy Markdown

Would love this

@jfet97

Copy link
Copy Markdown
Contributor

Would fix #60658

@gabritto

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

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

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

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Gabriela Araujo Britto (@gabritto), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the user tests with tsc comparing main and refs/pull/60644/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3434~~~p=1.000 n=6
Symbols62,36362,363~~~p=1.000 n=6
Types50,39550,395~~~p=1.000 n=6
Memory used193,618k (± 0.75%)193,636k (± 0.76%)~193,007k196,637kp=0.378 n=6
Parse Time1.31s (± 0.89%)1.31s (± 0.92%)~1.29s1.32sp=0.388 n=6
Bind Time0.72s0.72s~~~p=1.000 n=6
Check Time9.83s (± 0.51%)9.80s (± 0.56%)~9.73s9.87sp=0.377 n=6
Emit Time2.74s (± 1.31%)2.73s (± 0.52%)~2.71s2.75sp=0.934 n=6
Total Time14.59s (± 0.29%)14.56s (± 0.36%)~14.48s14.61sp=0.518 n=6
angular-1 - node (v18.15.0, x64)
Errors3737~~~p=1.000 n=6
Symbols947,936947,936~~~p=1.000 n=6
Types410,955410,955~~~p=1.000 n=6
Memory used1,225,985k (± 0.00%)1,226,011k (± 0.00%)~1,225,989k1,226,048kp=0.065 n=6
Parse Time6.67s (± 0.65%)6.66s (± 0.64%)~6.61s6.71sp=0.809 n=6
Bind Time1.88s (± 0.29%)1.88s (± 0.40%)~1.87s1.89sp=0.476 n=6
Check Time31.98s (± 0.40%)32.04s (± 0.41%)~31.80s32.18sp=0.335 n=6
Emit Time15.17s (± 0.49%)15.16s (± 0.42%)~15.09s15.24sp=1.000 n=6
Total Time55.70s (± 0.28%)55.75s (± 0.28%)~55.47s55.90sp=0.630 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,501,6612,501,661~~~p=1.000 n=6
Types909,610909,610~~~p=1.000 n=6
Memory used2,319,041k (± 0.00%)2,319,069k (± 0.00%)~2,319,030k2,319,098kp=0.148 n=6
Parse Time9.30s (± 0.29%)9.29s (± 0.27%)~9.26s9.32sp=1.000 n=6
Bind Time2.15s (± 0.64%)2.17s (± 0.74%)~2.14s2.18sp=0.140 n=6
Check Time74.89s (± 0.49%)75.08s (± 1.54%)~73.47s77.04sp=0.810 n=6
Emit Time0.28s (± 2.26%)0.29s (± 4.29%)~0.27s0.30sp=0.591 n=6
Total Time86.63s (± 0.41%)86.83s (± 1.33%)~85.27s88.83sp=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2511,225,251~~~p=1.000 n=6
Types266,546266,546~~~p=1.000 n=6
Memory used2,354,183k (± 0.03%)2,354,055k (± 0.02%)~2,353,579k2,354,515kp=0.936 n=6
Parse Time5.23s (± 1.20%)5.21s (± 0.69%)~5.17s5.26sp=0.335 n=6
Bind Time1.78s (± 0.84%)1.77s (± 1.13%)~1.75s1.80sp=0.288 n=6
Check Time35.22s (± 0.28%)35.21s (± 0.11%)~35.16s35.25sp=0.688 n=6
Emit Time3.03s (± 3.77%)2.96s (± 1.51%)~2.89s3.02sp=0.261 n=6
Total Time45.28s (± 0.34%)45.18s (± 0.09%)~45.12s45.24sp=0.378 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,225,2511,225,251~~~p=1.000 n=6
Types266,546266,546~~~p=1.000 n=6
Memory used3,028,519k (± 9.75%)2,908,400k (±12.88%)~2,423,421k3,150,982kp=0.298 n=6
Parse Time6.96s (± 1.54%)6.97s (± 2.00%)~6.78s7.12sp=0.575 n=6
Bind Time2.15s (± 2.08%)2.15s (± 1.40%)~2.10s2.18sp=0.936 n=6
Check Time42.80s (± 0.37%)42.94s (± 0.52%)~42.67s43.27sp=0.378 n=6
Emit Time3.50s (± 2.04%)3.49s (± 3.59%)~3.40s3.73sp=0.575 n=6
Total Time55.41s (± 0.41%)55.55s (± 0.59%)~55.01s55.99sp=0.230 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols262,223262,223~~~p=1.000 n=6
Types106,607106,607~~~p=1.000 n=6
Memory used439,832k (± 0.01%)439,799k (± 0.01%)~439,701k439,856kp=0.378 n=6
Parse Time3.53s (± 0.43%)3.53s (± 0.77%)~3.50s3.57sp=1.000 n=6
Bind Time1.31s (± 0.62%)1.31s (± 1.40%)~1.28s1.33sp=0.801 n=6
Check Time18.89s (± 0.34%)18.88s (± 0.24%)~18.82s18.94sp=0.687 n=6
Emit Time1.52s (± 1.34%)1.53s (± 1.64%)~1.50s1.57sp=1.000 n=6
Total Time25.25s (± 0.28%)25.24s (± 0.19%)~25.19s25.30sp=0.936 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors7070~~~p=1.000 n=6
Symbols226,062226,062~~~p=1.000 n=6
Types94,48894,488~~~p=1.000 n=6
Memory used371,661k (± 0.04%)371,689k (± 0.06%)~371,495k371,988kp=0.810 n=6
Parse Time2.90s (± 1.62%)2.87s (± 0.42%)~2.85s2.88sp=0.331 n=6
Bind Time1.58s (± 1.29%)1.58s (± 0.77%)~1.57s1.60sp=0.745 n=6
Check Time16.48s (± 0.41%)16.48s (± 0.23%)~16.43s16.53sp=0.936 n=6
Emit Time0.00s0.00s (±244.70%)~0.00s0.01sp=0.405 n=6
Total Time20.97s (± 0.37%)20.94s (± 0.26%)~20.87s21.01sp=0.629 n=6
vscode - node (v18.15.0, x64)
Errors44~~~p=1.000 n=6
Symbols3,188,8373,188,837~~~p=1.000 n=6
Types1,096,7441,096,744~~~p=1.000 n=6
Memory used3,263,160k (± 0.01%)3,263,009k (± 0.01%)~3,262,590k3,263,645kp=0.471 n=6
Parse Time14.15s (± 0.77%)14.11s (± 0.41%)~14.04s14.20sp=0.335 n=6
Bind Time4.60s (± 3.05%)4.68s (± 2.49%)~4.52s4.77sp=0.519 n=6
Check Time89.03s (± 3.25%)86.44s (± 0.64%)~85.60s87.05sp=0.109 n=6
Emit Time26.77s (±10.67%)28.31s (± 2.64%)~27.27s28.90sp=0.810 n=6
Total Time134.55s (± 0.86%)133.54s (± 0.87%)~131.82s134.55sp=0.173 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols288,733288,733~~~p=1.000 n=6
Types117,152117,152~~~p=1.000 n=6
Memory used440,955k (± 0.04%)441,009k (± 0.03%)~440,883k441,242kp=0.298 n=6
Parse Time4.10s (± 0.51%)4.08s (± 0.51%)~4.06s4.11sp=0.289 n=6
Bind Time1.75s (± 3.21%)1.74s (± 1.34%)~1.71s1.77sp=0.810 n=6
Check Time18.87s (± 0.42%)18.88s (± 0.29%)~18.80s18.95sp=0.936 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time24.72s (± 0.52%)24.71s (± 0.27%)~24.62s24.78sp=0.689 n=6
xstate-main - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols552,390552,390~~~p=1.000 n=6
Types185,096185,096~~~p=1.000 n=6
Memory used492,423k (± 0.03%)492,461k (± 0.04%)~492,112k492,640kp=0.689 n=6
Parse Time3.40s (± 0.73%)3.42s (± 0.35%)~3.41s3.44sp=0.283 n=6
Bind Time1.18s (± 1.03%)1.17s (± 1.17%)~1.16s1.19sp=0.286 n=6
Check Time19.65s (± 1.25%)19.55s (± 0.85%)~19.40s19.86sp=0.630 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time24.24s (± 1.02%)24.14s (± 0.65%)~24.01s24.44sp=0.521 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/60644/merge:

Everything looks good!

@gabritto

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
pack this✅ Started✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

Hey Gabriela Araujo Britto (@gabritto), 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/164255/artifacts?artifactName=tgz&fileId=EE4806BE35BC77ED3673245ECA2612801A455CE794E0A2BBF4926021973E02A302&fileName=/typescript-5.8.0-insiders.20241202.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@5.8.0-pr-60644-12".;

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch statements exhaustiveness check is failing when the expression has generic type but with literal type constraint

7 participants

@Andarist@typescript-bot@jfet97@Jontii@gabritto@sandersn@jakebailey