Skip to content

Allow implicit return with explicit undefined return type - #53092

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 9 commits into
microsoft:mainfrom
saschanaz:return-undefined
Mar 17, 2023
Merged

Allow implicit return with explicit undefined return type#53092
Daniel Rosenwasser (DanielRosenwasser) merged 9 commits into
microsoft:mainfrom
saschanaz:return-undefined

Conversation

@saschanaz

Copy link
Copy Markdown
Contributor

Fixes#36288

@typescript-botTypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 4, 2023
@typescript-bot

Copy link
Copy Markdown
Contributor

The TypeScript team hasn't accepted the linked issue #36288. If you can get it accepted, this PR will have a better chance of being reviewed.


function f9(): void {
function f9(): any {
// Fine since we are typed any and return undefined

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

(To match the comments, as otherwise these two are exactly same with f5 and f6.)

@jakebailey

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the diff-based top-repos suite on this PR at 3bee8eb. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the tarball bundle task on this PR at 3bee8eb. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the parallelized Definitely Typed test suite on this PR at 3bee8eb. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the extended test suite on this PR at 3bee8eb. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the perf test suite on this PR at 3bee8eb. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Heya Jake Bailey (@jakebailey), I've started to run the diff-based user code test suite on this PR at 3bee8eb. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 4, 2023

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@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/148246/artifacts?artifactName=tgz&fileId=82C1D525C0488DE608808B718A39774814B6F87A373D180D94EA38CA7D69C2B002&fileName=/typescript-5.1.0-insiders.20230304.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.1.0-pr-53092-8".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user test suite comparing main and refs/pull/53092/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..53092
Metricmain53092DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used359,740k (± 0.02%)359,775k (± 0.02%)~359,686k359,853kp=0.575 n=6
Parse Time3.48s (± 0.80%)3.48s (± 0.62%)~3.45s3.51sp=0.747 n=6
Bind Time1.13s (± 0.74%)1.13s (± 0.56%)~1.12s1.14sp=0.226 n=6
Check Time8.66s (± 0.54%)8.64s (± 0.53%)~8.59s8.72sp=0.629 n=6
Emit Time7.43s (± 0.35%)7.41s (± 0.71%)~7.33s7.49sp=0.257 n=6
Total Time20.69s (± 0.29%)20.65s (± 0.28%)~20.59s20.76sp=0.171 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used192,551k (± 1.49%)191,706k (± 1.23%)~190,593k196,526kp=0.810 n=6
Parse Time1.49s (± 0.55%)1.48s (± 1.16%)~1.46s1.51sp=0.452 n=6
Bind Time0.77s (± 0.67%)0.77s (± 0.98%)~0.76s0.78sp=0.784 n=6
Check Time9.35s (± 0.57%)9.38s (± 0.63%)~9.32s9.49sp=0.935 n=6
Emit Time2.73s (± 1.05%)2.73s (± 0.54%)~2.71s2.75sp=0.746 n=6
Total Time14.33s (± 0.53%)14.36s (± 0.42%)~14.30s14.47sp=0.936 n=6
Monaco - node (v18.10.0, x64)
Memory used343,850k (± 0.01%)343,857k (± 0.01%)~343,812k343,921kp=0.689 n=6
Parse Time2.63s (± 0.39%)2.62s (± 0.92%)~2.60s2.66sp=0.462 n=6
Bind Time1.00s (± 1.22%)1.01s (± 0.81%)~1.00s1.02sp=1.000 n=6
Check Time7.00s (± 0.52%)6.99s (± 0.71%)~6.93s7.05sp=0.574 n=6
Emit Time4.24s (± 0.77%)4.23s (± 0.55%)~4.20s4.26sp=0.686 n=6
Total Time14.88s (± 0.41%)14.85s (± 0.51%)~14.75s14.95sp=0.377 n=6
TFS - node (v18.10.0, x64)
Memory used299,880k (± 0.01%)299,866k (± 0.01%)~299,843k299,918kp=0.298 n=6
Parse Time2.04s (± 0.51%)2.04s (± 0.98%)~2.01s2.06sp=0.461 n=6
Bind Time1.13s (± 0.36%)1.14s (± 0.66%)~1.13s1.15sp=0.100 n=6
Check Time6.49s (± 0.42%)6.50s (± 0.38%)~6.47s6.54sp=1.000 n=6
Emit Time3.85s (± 0.73%)3.83s (± 0.60%)~3.80s3.87sp=0.375 n=6
Total Time13.51s (± 0.27%)13.51s (± 0.43%)~13.46s13.62sp=0.518 n=6
material-ui - node (v18.10.0, x64)
Memory used476,423k (± 0.00%)476,438k (± 0.00%)+14k (+ 0.00%)476,430k476,450kp=0.020 n=6
Parse Time3.11s (± 0.43%)3.11s (± 0.72%)~3.08s3.13sp=0.744 n=6
Bind Time0.91s (± 0.57%)0.91s (± 0.98%)~0.90s0.92sp=0.541 n=6
Check Time17.06s (± 0.44%)17.02s (± 0.44%)~16.93s17.13sp=0.520 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time21.07s (± 0.37%)21.04s (± 0.34%)~20.96s21.12sp=0.810 n=6
xstate - node (v18.10.0, x64)
Memory used548,865k (± 0.02%)548,948k (± 0.02%)~548,848k549,094kp=0.173 n=6
Parse Time4.07s (± 0.55%)4.07s (± 0.41%)~4.05s4.09sp=0.627 n=6
Bind Time1.67s (± 0.59%)1.66s (± 0.62%)~1.65s1.67sp=0.557 n=6
Check Time2.76s (± 0.74%)2.75s (± 0.65%)~2.73s2.78sp=0.466 n=6
Emit Time0.08s (± 4.99%)0.08s (± 4.99%)~0.08s0.09sp=1.000 n=6
Total Time8.58s (± 0.38%)8.57s (± 0.26%)~8.54s8.61sp=0.870 n=6
Angular - node (v16.17.1, x64)
Memory used359,078k (± 0.00%)359,088k (± 0.01%)~359,035k359,127kp=0.298 n=6
Parse Time3.72s (± 0.22%)3.71s (± 0.20%)~3.70s3.72sp=0.652 n=6
Bind Time1.19s (± 0.46%)1.19s (± 0.63%)~1.18s1.20sp=0.137 n=6
Check Time9.42s (± 0.62%)9.41s (± 0.56%)~9.33s9.49sp=0.627 n=6
Emit Time7.90s (± 0.84%)7.88s (± 0.54%)~7.84s7.95sp=0.572 n=6
Total Time22.23s (± 0.25%)22.19s (± 0.17%)~22.13s22.24sp=0.196 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used192,383k (± 0.03%)192,348k (± 0.02%)~192,315k192,428kp=0.521 n=6
Parse Time1.56s (± 0.52%)1.56s (± 1.43%)~1.52s1.58sp=0.739 n=6
Bind Time0.82s (± 0.00%)0.82s (± 0.63%)~0.82s0.83sp=0.174 n=6
Check Time10.12s (± 0.60%)10.11s (± 0.39%)~10.04s10.15sp=0.809 n=6
Emit Time2.98s (± 0.86%)2.98s (± 0.97%)~2.95s3.03sp=0.567 n=6
Total Time15.48s (± 0.45%)15.46s (± 0.18%)~15.43s15.50sp=0.748 n=6
Monaco - node (v16.17.1, x64)
Memory used343,113k (± 0.00%)343,105k (± 0.00%)~343,081k343,121kp=0.574 n=6
Parse Time2.79s (± 0.27%)2.79s (± 0.54%)~2.78s2.82sp=0.503 n=6
Bind Time1.08s (± 0.76%)1.08s (± 0.59%)~1.07s1.09sp=0.599 n=6
Check Time7.67s (± 0.37%)7.65s (± 0.41%)~7.62s7.69sp=0.373 n=6
Emit Time4.42s (± 0.44%)4.42s (± 0.49%)~4.38s4.44sp=0.868 n=6
Total Time15.97s (± 0.18%)15.96s (± 0.25%)~15.90s16.00sp=0.806 n=6
TFS - node (v16.17.1, x64)
Memory used299,227k (± 0.01%)299,236k (± 0.01%)~299,202k299,253kp=0.297 n=6
Parse Time2.17s (± 0.48%)2.17s (± 0.86%)~2.14s2.19sp=0.935 n=6
Bind Time1.24s (± 0.41%)1.24s (± 0.33%)~1.24s1.25sp=0.595 n=6
Check Time7.17s (± 0.39%)7.16s (± 0.28%)~7.14s7.19sp=0.624 n=6
Emit Time4.33s (± 0.65%)4.33s (± 0.61%)~4.30s4.38sp=1.000 n=6
Total Time14.91s (± 0.15%)14.91s (± 0.30%)~14.86s14.98sp=0.624 n=6
material-ui - node (v16.17.1, x64)
Memory used475,669k (± 0.01%)475,658k (± 0.00%)~475,629k475,677kp=0.336 n=6
Parse Time3.28s (± 0.42%)3.28s (± 0.32%)~3.27s3.30sp=1.000 n=6
Bind Time0.96s (± 0.57%)0.96s (± 0.54%)~0.95s0.96sp=0.640 n=6
Check Time17.99s (± 0.24%)18.03s (± 0.35%)~17.96s18.12sp=0.419 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.23s (± 0.16%)22.27s (± 0.31%)~22.20s22.39sp=0.261 n=6
xstate - node (v16.17.1, x64)
Memory used546,456k (± 0.02%)546,450k (± 0.02%)~546,316k546,619kp=0.936 n=6
Parse Time4.28s (± 0.54%)4.26s (± 0.27%)~4.24s4.27sp=0.169 n=6
Bind Time1.77s (± 0.46%)1.76s (± 0.43%)~1.75s1.77sp=0.120 n=6
Check Time2.98s (± 0.76%)2.96s (± 0.50%)~2.95s2.98sp=0.120 n=6
Emit Time0.09s (± 5.53%)0.09s (± 4.45%)~0.09s0.10sp=0.595 n=6
Total Time9.11s (± 0.36%)9.08s (± 0.22%)-0.04s (- 0.40%)9.05s9.11sp=0.041 n=6
Angular - node (v14.15.1, x64)
Memory used352,866k (± 0.00%)352,876k (± 0.00%)~352,858k352,890kp=0.199 n=6
Parse Time3.71s (± 0.37%)3.69s (± 0.37%)~3.68s3.72sp=0.158 n=6
Bind Time1.25s (± 0.60%)1.25s (± 0.97%)~1.24s1.27sp=0.485 n=6
Check Time9.73s (± 0.31%)9.71s (± 0.85%)~9.60s9.82sp=1.000 n=6
Emit Time8.29s (± 0.35%)8.32s (± 0.83%)~8.25s8.44sp=1.000 n=6
Total Time22.98s (± 0.26%)22.97s (± 0.57%)~22.83s23.14sp=0.810 n=6
Compiler-Unions - node (v14.15.1, x64)
Memory used187,621k (± 0.01%)187,629k (± 0.01%)~187,604k187,656kp=0.689 n=6
Parse Time1.57s (± 0.80%)1.58s (± 0.87%)~1.56s1.59sp=0.564 n=6
Bind Time0.84s (± 0.00%)0.84s (± 0.75%)~0.83s0.85sp=1.000 n=6
Check Time10.15s (± 0.60%)10.16s (± 0.55%)~10.11s10.25sp=0.870 n=6
Emit Time3.12s (± 0.92%)3.13s (± 0.72%)~3.09s3.15sp=0.466 n=6
Total Time15.67s (± 0.45%)15.70s (± 0.52%)~15.64s15.83sp=0.810 n=6
Monaco - node (v14.15.1, x64)
Memory used338,108k (± 0.00%)338,133k (± 0.01%)+25k (+ 0.01%)338,105k338,162kp=0.037 n=6
Parse Time2.87s (± 0.46%)2.87s (± 0.92%)~2.84s2.91sp=0.742 n=6
Bind Time1.10s (± 0.94%)1.09s (± 0.50%)~1.09s1.10sp=0.138 n=6
Check Time8.07s (± 0.50%)8.08s (± 0.35%)~8.04s8.11sp=0.685 n=6
Emit Time4.67s (± 1.03%)4.67s (± 0.66%)~4.64s4.73sp=0.808 n=6
Total Time16.72s (± 0.45%)16.72s (± 0.19%)~16.68s16.77sp=0.630 n=6
TFS - node (v14.15.1, x64)
Memory used294,292k (± 0.00%)294,296k (± 0.01%)~294,265k294,309kp=0.748 n=6
Parse Time2.37s (± 1.05%)2.38s (± 0.57%)~2.36s2.40sp=0.462 n=6
Bind Time1.06s (± 0.38%)1.06s (± 0.60%)~1.05s1.07sp=0.673 n=6
Check Time7.42s (± 0.47%)7.47s (± 0.61%)~7.43s7.54sp=0.250 n=6
Emit Time4.26s (± 0.75%)4.28s (± 0.36%)~4.26s4.30sp=0.217 n=6
Total Time15.11s (± 0.40%)15.19s (± 0.47%)~15.12s15.31sp=0.092 n=6
material-ui - node (v14.15.1, x64)
Memory used471,392k (± 0.00%)471,362k (± 0.00%)-31k (- 0.01%)471,338k471,385kp=0.020 n=6
Parse Time3.45s (± 0.51%)3.45s (± 0.57%)~3.42s3.47sp=1.000 n=6
Bind Time1.00s (± 1.04%)1.00s (± 0.75%)~0.99s1.01sp=0.273 n=6
Check Time18.91s (± 0.34%)18.95s (± 0.59%)~18.88s19.18sp=0.467 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time23.37s (± 0.28%)23.40s (± 0.53%)~23.30s23.64sp=0.936 n=6
xstate - node (v14.15.1, x64)
Memory used535,172k (± 0.00%)535,172k (± 0.00%)~535,156k535,200kp=0.810 n=6
Parse Time4.45s (± 0.46%)4.47s (± 0.52%)~4.43s4.50sp=0.417 n=6
Bind Time1.79s (± 0.46%)1.79s (± 0.50%)~1.78s1.80sp=0.550 n=6
Check Time3.18s (± 0.59%)3.16s (± 0.66%)~3.14s3.19sp=0.259 n=6
Emit Time0.09s (± 4.45%)0.09s (± 0.00%)~0.09s0.09sp=0.405 n=6
Total Time9.51s (± 0.38%)9.51s (± 0.44%)~9.44s9.56sp=0.748 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)
BenchmarkNameIterations
Current530926
Baselinemain6

TSServer

Comparison Report - main..53092
Metricmain53092DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,359ms (± 0.46%)2,365ms (± 0.64%)~2,350ms2,392msp=0.628 n=6
Req 2 - geterr5,337ms (± 0.24%)5,337ms (± 0.47%)~5,303ms5,366msp=1.000 n=6
Req 3 - references325ms (± 0.45%)330ms (± 1.19%)~325ms336msp=0.053 n=6
Req 4 - navto285ms (± 0.72%)283ms (± 0.84%)~280ms286msp=0.170 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo79ms (± 1.13%)81ms (± 7.67%)~72ms89msp=0.677 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,516ms (± 0.66%)2,497ms (± 0.75%)~2,474ms2,526msp=0.109 n=6
Req 2 - geterr4,009ms (± 0.59%)4,003ms (± 0.53%)~3,974ms4,035msp=0.470 n=6
Req 3 - references346ms (± 0.72%)348ms (± 0.76%)~346ms353msp=0.195 n=6
Req 4 - navto292ms (± 0.80%)293ms (± 0.29%)~291ms293msp=0.797 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo72ms (± 4.68%)77ms (± 5.46%)~72ms84msp=0.059 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,168ms (± 0.37%)3,159ms (± 0.57%)~3,132ms3,183msp=0.469 n=6
Req 2 - geterr1,600ms (± 0.44%)1,599ms (± 0.96%)~1,582ms1,621msp=1.000 n=6
Req 3 - references103ms (± 2.42%)103ms (± 1.13%)~102ms105msp=0.677 n=6
Req 4 - navto360ms (± 1.35%)361ms (± 1.51%)~354ms371msp=0.257 n=6
Req 5 - completionInfo count3,136 (± 0.00%)3,136 (± 0.00%)~3,1363,136p=1.000 n=6
Req 5 - completionInfo428ms (± 0.46%)425ms (± 1.47%)~416ms434msp=0.465 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,476ms (± 1.27%)2,471ms (± 1.59%)~2,429ms2,523msp=0.810 n=6
Req 2 - geterr5,728ms (± 0.55%)5,736ms (± 0.58%)~5,677ms5,774msp=0.689 n=6
Req 3 - references342ms (± 0.68%)342ms (± 0.73%)~339ms345msp=0.870 n=6
Req 4 - navto279ms (± 1.69%)278ms (± 0.75%)~275ms280msp=0.805 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo94ms (± 4.70%)91ms (± 5.93%)~84ms97msp=0.220 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,672ms (± 1.01%)2,682ms (± 0.32%)~2,673ms2,695msp=1.000 n=6
Req 2 - geterr4,362ms (± 0.22%)4,364ms (± 0.41%)~4,342ms4,388msp=0.936 n=6
Req 3 - references360ms (± 0.53%)357ms (± 0.74%)~354ms361msp=0.053 n=6
Req 4 - navto288ms (± 0.74%)291ms (± 0.42%)+2ms (+ 0.81%)289ms292msp=0.050 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo76ms (± 3.72%)75ms (± 3.53%)~72ms78msp=0.867 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,345ms (± 0.25%)3,343ms (± 0.26%)~3,329ms3,353msp=0.572 n=6
Req 2 - geterr1,733ms (± 1.32%)1,739ms (± 1.07%)~1,709ms1,759msp=0.520 n=6
Req 3 - references112ms (± 0.88%)112ms (± 1.26%)~110ms114msp=0.869 n=6
Req 4 - navto345ms (± 1.41%)344ms (± 1.56%)~339ms352msp=0.871 n=6
Req 5 - completionInfo count3,136 (± 0.00%)3,136 (± 0.00%)~3,1363,136p=1.000 n=6
Req 5 - completionInfo433ms (± 0.86%)435ms (± 0.67%)~432ms439msp=0.573 n=6
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen2,568ms (± 0.44%)2,563ms (± 1.00%)~2,524ms2,585msp=1.000 n=6
Req 2 - geterr6,045ms (± 0.31%)6,066ms (± 0.43%)~6,033ms6,104msp=0.199 n=6
Req 3 - references359ms (± 0.27%)358ms (± 0.49%)~355ms360msp=0.117 n=6
Req 4 - navto275ms (± 0.54%)277ms (± 1.22%)~273ms283msp=0.330 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo101ms (± 2.14%)99ms (± 4.62%)~91ms103msp=0.864 n=6
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen2,824ms (± 0.67%)2,814ms (± 0.30%)~2,802ms2,828msp=0.258 n=6
Req 2 - geterr4,438ms (± 0.44%)4,446ms (± 0.54%)~4,418ms4,480msp=0.689 n=6
Req 3 - references402ms (± 6.88%)384ms (± 6.50%)~364ms418msp=0.196 n=6
Req 4 - navto290ms (± 1.47%)293ms (± 1.66%)~285ms297msp=0.145 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo98ms (± 3.32%)95ms (± 7.90%)~85ms102msp=0.357 n=6
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen3,652ms (± 0.24%)3,649ms (± 0.25%)~3,639ms3,659msp=1.000 n=6
Req 2 - geterr1,841ms (± 0.83%)1,847ms (± 0.94%)~1,819ms1,863msp=0.575 n=6
Req 3 - references129ms (± 1.79%)129ms (± 2.86%)~123ms132msp=1.000 n=6
Req 4 - navto375ms (± 0.99%)374ms (± 1.26%)~368ms382msp=0.421 n=6
Req 5 - completionInfo count3,136 (± 0.00%)3,136 (± 0.00%)~3,1363,136p=1.000 n=6
Req 5 - completionInfo449ms (± 3.36%)449ms (± 2.64%)~438ms468msp=0.748 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)
BenchmarkNameIterations
Current530926
Baselinemain6

Startup

Comparison Report - main..53092
Metricmain53092DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time141.53ms (± 0.24%)141.47ms (± 0.19%)~140.82ms143.79msp=0.073 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time226.58ms (± 0.19%)226.68ms (± 0.15%)+0.09ms (+ 0.04%)225.58ms231.00msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time228.44ms (± 0.15%)228.64ms (± 0.16%)+0.20ms (+ 0.09%)227.68ms232.87msp=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time209.31ms (± 0.16%)209.19ms (± 0.14%)-0.12ms (- 0.06%)208.40ms213.27msp=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)
BenchmarkNameIterations
Current530926
Baselinemain6

Developer Information:

Download Benchmark

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), 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

Jake Bailey (@jakebailey) Here are the results of running the top-repos suite comparing main and refs/pull/53092/merge:

Everything looks good!

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just add one more test case with a union type (EDIT: let me know if I missed another case in the same file).

@DanielRosenwasser

Copy link
Copy Markdown
Member

There's this check below your code

elseif(type&&strictNullChecks&&!isTypeAssignableTo(undefinedType,type)){error(errorNode,Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);}

Do we need the assignability check anymore?

- else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {+ else if (type && strictNullChecks) {
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
}

…xpressions.errors.txt
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
// Okay; return type allows implicit return of undefined
}

function f23(): undefined | number {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think your last commit only included this baseline, as f23 doesn't appear to be anywhere else.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I just tapped the commit button from GitHub, will add it with the another change for the feedback.

@saschanaz

Kagami Sascha Rosylight (saschanaz) commented Mar 6, 2023

Copy link
Copy Markdown
ContributorAuthor

Do we need the assignability check anymore?

I'm not sure, isn't that for some different situation, as there's still a test for that:

classA{
a(): string|null{
if(Math.random()>0.5){
return'';
}
// it does error here as expected
}
}

==== tests/cases/compiler/getterControlFlowStrictNull.ts (3 errors) ====
class A {
a(): string | null {
~~~~~~~~~~~~~
!!! error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
if (Math.random() > 0.5) {
return '';
}
// it does error here as expected
}
}

@DanielRosenwasser

Copy link
Copy Markdown
Member

You're saying that TypeScript no longer issues an error in that test if you remove that assignability check? I can't see why that would happen.

@saschanaz

Kagami Sascha Rosylight (saschanaz) commented Mar 6, 2023

Copy link
Copy Markdown
ContributorAuthor

You're saying that TypeScript no longer issues an error in that test if you remove that assignability check? I can't see why that would happen.

Oh, you want to change the error? Okay then 👀 Scratch it, I guess I need coffee.

Comment threadsrc/compiler/diagnosticMessages.json Outdated
"code": 2354
},
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
"A function whose declared type is neither 'void' nor 'any' must return a value. 'undefined' is also allowed with --strictNullChecks.": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I'd rather us duplicate this message to have two (Daniel Rosenwasser (@DanielRosenwasser) may be able to better write these):

A function whose declared type is neither 'void' nor 'any' must return a value.

A function whose declared type is not 'void', 'any', or 'undefined' must return a value.

Then, conditionally emit one based on the variable strictNullChecks.

Then below in codefixes/returnValueCorrect.ts, handle both.

@jakebaileyJake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but deferring to Daniel Rosenwasser (@DanielRosenwasser) for diagnostic wording.

}
}
else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
else if (type && strictNullChecks) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Jake Bailey (@jakebailey)Daniel Rosenwasser (@DanielRosenwasser) The removal of this assignability check has caused a regression. This example now errors when it shouldn't:

functionfx2(x: boolean): unknown{if(x){return"hello";}};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I noticed the regression here: #53515 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Funny. We were just talking about adding this check back again in #53490

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'll look into why it's not working as we expected.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, no, that PR was exactly to fix the issue you mentioned. So it should be fixed in main now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked, and it is fixed, yep.

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

Archived in project

Development

Successfully merging this pull request may close these issues.

Allow non returning functions to have contextually required undefined return type

6 participants

@saschanaz@typescript-bot@jakebailey@DanielRosenwasser@ahejlsberg@sandersn