Skip to content

Avoid creating rest elements with errorType when any is spread - #57116

Merged
Gabriela Araujo Britto (gabritto) merged 4 commits into
microsoft:mainfrom
Andarist:fix/any-rest
Feb 16, 2024
Merged

Avoid creating rest elements with errorType when any is spread#57116
Gabriela Araujo Britto (gabritto) merged 4 commits into
microsoft:mainfrom
Andarist:fix/any-rest

Conversation

@Andarist

@AndaristMateusz Burzyński (Andarist) commented Jan 21, 2024

Copy link
Copy Markdown
Contributor

This isn't particularly observable as far as I know. However, it turns out that currently [...any] is normalized~ to [...errorType]. errorType is a special any and displays as such, so this went unnoticed. However, since [...any] is legal it doesn't make sense to produce errorType in this situation at all.

EDIT:// this is more observable than what I've described above. I just pushed out a test for this. This PR fixes#55932 that was incorrectly~ attributed to be a duplicate of #29919

fixes#57389

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

>(function(a, ...rest) {})('', true, ...itNum) : void
>(function(a, ...rest) {}) : (a: string, rest_0: boolean, ...rest_1: any[]) => void
>function(a, ...rest) {} : (a: string, rest_0: boolean, ...rest_1: any[]) => void
>(function(a, ...rest) {}) : (a: string, rest_0: boolean, ...rest_1: Iterable<number>[]) => void

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.

This test targets es5 where Iterable doesn't exist. This change shows how now an unresolved type continues to be displayed with its alias name~. Just like here:

typeTest={foo: Thing;// even though it's unresolved and errors, it is still displayed as `Thing`};

And actually, this matches the display of those IIFEs above this one. So it turns out that this one was going through createNormalizedTupleType that accidentally lost this display value.

@fatcerberus

Copy link
Copy Markdown

normalized~

incorrectly~

I still haven’t figured out how to interpret these tildes in your text

@Andarist

Copy link
Copy Markdown
ContributorAuthor

😅 I use this as a softener of sorts - when I'm not sure if the used term is 100% precise etc ;p Sorry for making it confusing, I'm not sure where I got it from.

@sandersn

Copy link
Copy Markdown
Member

Turns out this is a fix for a break introduced in #57031 and reported a few days ago in #57389

Anders Hejlsberg (@ahejlsberg)Mateusz Burzyński (@Andarist) reported this as bug in #57389. Can you confirm and decide whether it's worth taking in 5.4?

@sandersn

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Nathan Shively-Sanders (@sandersn), I've started to run the tarball bundle task on this PR at a08d7d7. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Nathan Shively-Sanders (@sandersn), I've started to run the regular perf test suite on this PR at a08d7d7. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Nathan Shively-Sanders (@sandersn), I've started to run the diff-based top-repos suite on this PR at a08d7d7. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Nathan Shively-Sanders (@sandersn), I've started to run the diff-based user code test suite on this PR at a08d7d7. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized Definitely Typed test suite on this PR at a08d7d7. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Hey Nathan Shively-Sanders (@sandersn), 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/159886/artifacts?artifactName=tgz&fileId=C72CA42D20EE93ADA8F6F6CC4DFB188E1B49BF166381F05C30B18C5179E1A6EC02&fileName=/typescript-5.4.0-insiders.20240215.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.4.0-pr-57116-10".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Nathan Shively-Sanders (@sandersn) Here are the results of running the user test suite comparing main and refs/pull/57116/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Nathan Shively-Sanders (@sandersn), 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

Nathan Shively-Sanders (@sandersn) Here are the results of running the top-repos suite comparing main and refs/pull/57116/merge:

Everything looks good!

@DanielRosenwasser

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test top200

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the diff-based top-repos suite on this PR at a08d7d7. You can monitor the build here.

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser) Here are the results of running the top-repos suite comparing main and refs/pull/57116/merge:

Everything looks good!

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) perf test this

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

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

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,668k (± 0.01%)295,670k (± 0.01%)~295,637k295,710kp=0.936 n=6
Parse Time2.66s (± 0.60%)2.66s (± 0.37%)~2.65s2.68sp=0.446 n=6
Bind Time0.83s (± 1.65%)0.83s (± 1.19%)~0.82s0.84sp=0.401 n=6
Check Time8.26s (± 0.21%)8.23s (± 0.46%)~8.19s8.28sp=0.170 n=6
Emit Time7.10s (± 0.34%)7.12s (± 0.19%)~7.10s7.13sp=0.411 n=6
Total Time18.86s (± 0.11%)18.84s (± 0.15%)~18.81s18.87sp=0.191 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used191,608k (± 0.02%)194,008k (± 1.48%)~191,591k197,527kp=0.066 n=6
Parse Time1.36s (± 0.98%)1.36s (± 0.76%)~1.35s1.38sp=0.492 n=6
Bind Time0.72s (± 0.00%)0.72s (± 0.00%)~0.72s0.72sp=1.000 n=6
Check Time9.38s (± 0.52%)9.37s (± 0.27%)~9.32s9.39sp=0.332 n=6
Emit Time2.62s (± 0.45%)2.62s (± 0.80%)~2.58s2.64sp=0.561 n=6
Total Time14.08s (± 0.31%)14.08s (± 0.19%)~14.04s14.11sp=0.685 n=6
Monaco - node (v18.15.0, x64)
Memory used347,473k (± 0.00%)347,487k (± 0.01%)~347,454k347,502kp=0.128 n=6
Parse Time2.47s (± 0.55%)2.48s (± 0.59%)~2.46s2.50sp=0.742 n=6
Bind Time0.93s (± 0.44%)0.93s (± 0.56%)~0.92s0.93sp=0.595 n=6
Check Time6.96s (± 0.23%)6.99s (± 0.36%)~6.94s7.01sp=0.075 n=6
Emit Time4.08s (± 0.62%)4.06s (± 0.44%)~4.03s4.08sp=0.415 n=6
Total Time14.44s (± 0.19%)14.45s (± 0.24%)~14.39s14.49sp=0.459 n=6
TFS - node (v18.15.0, x64)
Memory used302,852k (± 0.00%)302,851k (± 0.01%)~302,826k302,876kp=0.810 n=6
Parse Time1.99s (± 1.13%)2.01s (± 0.83%)~2.00s2.04sp=0.413 n=6
Bind Time1.00s (± 1.03%)1.00s (± 0.41%)~1.00s1.01sp=0.924 n=6
Check Time6.32s (± 0.13%)6.36s (± 0.41%)+0.03s (+ 0.53%)6.32s6.38sp=0.048 n=6
Emit Time3.59s (± 0.62%)3.58s (± 0.52%)~3.56s3.60sp=0.363 n=6
Total Time12.91s (± 0.34%)12.95s (± 0.20%)~12.92s12.98sp=0.090 n=6
material-ui - node (v18.15.0, x64)
Memory used511,377k (± 0.00%)511,370k (± 0.00%)~511,359k511,377kp=1.000 n=6
Parse Time2.66s (± 0.51%)2.65s (± 0.72%)~2.63s2.68sp=0.357 n=6
Bind Time1.00s (± 1.04%)0.99s (± 1.05%)~0.98s1.01sp=0.801 n=6
Check Time17.26s (± 0.57%)17.28s (± 0.27%)~17.23s17.36sp=0.810 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.91s (± 0.44%)20.92s (± 0.25%)~20.86s21.02sp=0.809 n=6
mui-docs - node (v18.15.0, x64)
Memory used2,272,170k (± 0.00%)2,272,171k (± 0.00%)~2,272,141k2,272,226kp=0.873 n=6
Parse Time11.97s (± 0.55%)11.97s (± 0.86%)~11.83s12.07sp=1.000 n=6
Bind Time2.62s (± 0.29%)2.62s (± 0.16%)~2.61s2.62sp=0.389 n=6
Check Time102.27s (± 0.65%)102.35s (± 0.67%)~101.32s103.08sp=0.936 n=6
Emit Time0.32s (± 0.00%)0.32s (± 0.00%)~0.32s0.32sp=1.000 n=6
Total Time117.19s (± 0.55%)117.26s (± 0.64%)~116.09s118.09sp=0.936 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,412,874k (± 0.03%)2,412,475k (± 0.03%)~2,411,306k2,413,399kp=0.298 n=6
Parse Time4.93s (± 0.94%)4.91s (± 1.25%)~4.87s5.03sp=0.374 n=6
Bind Time1.87s (± 0.66%)1.88s (± 0.88%)~1.86s1.90sp=0.453 n=6
Check Time33.55s (± 0.41%)33.53s (± 0.32%)~33.32s33.62sp=0.936 n=6
Emit Time2.69s (± 1.19%)2.67s (± 1.45%)~2.61s2.72sp=0.261 n=6
Total Time43.08s (± 0.38%)43.01s (± 0.31%)~42.74s43.10sp=0.173 n=6
self-compiler - node (v18.15.0, x64)
Memory used418,853k (± 0.01%)418,860k (± 0.01%)~418,824k418,892kp=0.810 n=6
Parse Time2.76s (± 3.75%)2.78s (± 3.52%)~2.65s2.87sp=0.688 n=6
Bind Time1.13s (± 6.57%)1.12s (± 6.10%)~1.07s1.21sp=0.931 n=6
Check Time15.16s (± 0.18%)15.15s (± 0.36%)~15.08s15.23sp=0.571 n=6
Emit Time1.13s (± 0.87%)1.14s (± 2.03%)~1.11s1.17sp=0.412 n=6
Total Time20.18s (± 0.27%)20.19s (± 0.18%)~20.14s20.22sp=0.871 n=6
vscode - node (v18.15.0, x64)
Memory used2,844,126k (± 0.00%)2,844,056k (± 0.00%)-70k (- 0.00%)2,844,024k2,844,086kp=0.005 n=6
Parse Time10.76s (± 0.14%)10.76s (± 0.49%)~10.69s10.83sp=0.746 n=6
Bind Time3.44s (± 0.47%)3.44s (± 0.22%)~3.43s3.45sp=1.000 n=6
Check Time60.47s (± 0.37%)60.72s (± 0.40%)~60.46s61.04sp=0.109 n=6
Emit Time16.25s (± 0.60%)16.25s (± 0.68%)~16.13s16.40sp=1.000 n=6
Total Time90.92s (± 0.35%)91.17s (± 0.30%)~90.87s91.58sp=0.230 n=6
webpack - node (v18.15.0, x64)
Memory used394,109k (± 0.02%)394,162k (± 0.02%)~394,050k394,257kp=0.297 n=6
Parse Time3.12s (± 1.01%)3.12s (± 0.53%)~3.10s3.14sp=0.685 n=6
Bind Time1.39s (± 1.34%)1.39s (± 1.75%)~1.36s1.41sp=0.868 n=6
Check Time14.08s (± 0.34%)14.06s (± 0.42%)~13.97s14.13sp=0.572 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time18.58s (± 0.23%)18.56s (± 0.42%)~18.44s18.67sp=0.688 n=6
xstate - node (v18.15.0, x64)
Memory used513,377k (± 0.01%)513,359k (± 0.01%)~513,312k513,435kp=0.423 n=6
Parse Time3.27s (± 0.25%)3.27s (± 0.23%)~3.26s3.28sp=0.729 n=6
Bind Time1.54s (± 0.64%)1.54s (± 0.26%)~1.54s1.55sp=0.673 n=6
Check Time2.85s (± 0.82%)2.86s (± 0.65%)~2.84s2.89sp=0.517 n=6
Emit Time0.08s (± 5.21%)0.08s (± 0.00%)~0.08s0.08sp=0.405 n=6
Total Time7.75s (± 0.36%)7.76s (± 0.28%)~7.74s7.79sp=0.686 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

tsserver

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,340ms (± 0.62%)2,353ms (± 0.72%)~2,331ms2,372msp=0.230 n=6
Req 2 - geterr5,549ms (± 1.29%)5,531ms (± 1.43%)~5,437ms5,603msp=0.687 n=6
Req 3 - references324ms (± 1.34%)326ms (± 1.54%)~320ms331msp=1.000 n=6
Req 4 - navto276ms (± 1.12%)276ms (± 1.01%)~273ms279msp=0.625 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo85ms (± 9.67%)88ms (± 6.65%)~80ms95msp=0.464 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,481ms (± 0.54%)2,494ms (± 0.58%)~2,476ms2,512msp=0.092 n=6
Req 2 - geterr4,142ms (± 1.48%)4,165ms (± 1.76%)~4,114ms4,265msp=0.688 n=6
Req 3 - references336ms (± 1.56%)337ms (± 1.44%)~331ms343msp=0.682 n=6
Req 4 - navto285ms (± 0.44%)284ms (± 0.57%)~282ms286msp=0.504 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo88ms (± 5.34%)87ms (± 5.25%)~78ms90msp=0.718 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen2,612ms (± 0.36%)2,612ms (± 0.60%)~2,596ms2,637msp=1.000 n=6
Req 2 - geterr1,757ms (± 2.54%)1,739ms (± 3.61%)~1,650ms1,797msp=0.688 n=6
Req 3 - references117ms (± 9.23%)117ms (± 9.67%)~107ms129msp=0.806 n=6
Req 4 - navto370ms (± 0.85%)371ms (± 0.26%)~370ms372msp=0.558 n=6
Req 5 - completionInfo count2,078 (± 0.00%)2,078 (± 0.00%)~2,0782,078p=1.000 n=6
Req 5 - completionInfo312ms (± 1.11%)313ms (± 1.41%)~307ms316msp=0.367 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstateTSServer - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

startup

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
tsc-startup - node (v18.15.0, x64)
Execution time153.95ms (± 0.21%)153.61ms (± 0.19%)-0.35ms (- 0.23%)152.48ms157.45msp=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time229.84ms (± 0.16%)229.60ms (± 0.18%)-0.24ms (- 0.11%)228.11ms236.78msp=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time231.22ms (± 0.19%)231.17ms (± 0.17%)~229.64ms234.44msp=0.518 n=600
typescript-startup - node (v18.15.0, x64)
Execution time231.00ms (± 0.17%)231.06ms (± 0.16%)~229.73ms234.85msp=0.131 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DavidArchibald

David Archibald (DavidArchibald) commented Feb 22, 2024

Copy link
Copy Markdown

This is also observable with something like this:

typeSomeCallback<Argsextendsreadonlyany[]>=(...args: Args)=>void;functioncall<CallbackextendsSomeCallback<any>>(x: Callback,args: Parameters<Callback>){x(...args);// error, pre-PR: Type 'Parameters<Callback>' must have a '[Symbol.iterator]()' method that returns an iterator.(2488)}

Maybe this is just a simpler #55932 but I only knew how to fix this particular issue (which I actually ran into) because I've been reading the TypeScript issue tracker.

@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
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.

[TS 5.4.0-beta] Tuple type members being preserved Remapped generic array type Can't pass to rest parameters

9 participants

@Andarist@typescript-bot@fatcerberus@sandersn@DanielRosenwasser@jakebailey@DavidArchibald@gabritto@ahejlsberg