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

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

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jan 21, 2024

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-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 21, 2024
@typescript-bot
Copy link
Collaborator

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

@@ -24,10 +24,10 @@ declare const itNum: Iterable<number>

;(function(a, ...rest) {})('', true, ...itNum)
>(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
Contributor Author

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:

type Test = {
  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

normalized~

incorrectly~

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

@Andarist
Copy link
Contributor Author

😅 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 sandersn requested a review from ahejlsberg February 15, 2024 15:00
@sandersn sandersn requested a review from gabritto February 15, 2024 15:00
@sandersn sandersn added the For Milestone Bug PRs that fix a bug with a specific milestone label Feb 15, 2024
@typescript-bot typescript-bot removed the For Milestone Bug PRs that fix a bug with a specific milestone label Feb 15, 2024
@sandersn
Copy link
Member

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

@ahejlsberg @Andarist reported this as bug in #57389. Can you confirm and decide whether it's worth taking in 5.4?

@sandersn
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

Heya @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
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

Heya @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
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

Heya @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
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

Hey @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
Collaborator

@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
Collaborator

Hey @sandersn, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@DanielRosenwasser
Copy link
Member

@typescript-bot test top200

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 15, 2024

Heya @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
Collaborator

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

Everything looks good!

@jakebailey
Copy link
Member

@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 16, 2024

Heya @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
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,668k (± 0.01%) 295,670k (± 0.01%) ~ 295,637k 295,710k p=0.936 n=6
Parse Time 2.66s (± 0.60%) 2.66s (± 0.37%) ~ 2.65s 2.68s p=0.446 n=6
Bind Time 0.83s (± 1.65%) 0.83s (± 1.19%) ~ 0.82s 0.84s p=0.401 n=6
Check Time 8.26s (± 0.21%) 8.23s (± 0.46%) ~ 8.19s 8.28s p=0.170 n=6
Emit Time 7.10s (± 0.34%) 7.12s (± 0.19%) ~ 7.10s 7.13s p=0.411 n=6
Total Time 18.86s (± 0.11%) 18.84s (± 0.15%) ~ 18.81s 18.87s p=0.191 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 191,608k (± 0.02%) 194,008k (± 1.48%) ~ 191,591k 197,527k p=0.066 n=6
Parse Time 1.36s (± 0.98%) 1.36s (± 0.76%) ~ 1.35s 1.38s p=0.492 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.38s (± 0.52%) 9.37s (± 0.27%) ~ 9.32s 9.39s p=0.332 n=6
Emit Time 2.62s (± 0.45%) 2.62s (± 0.80%) ~ 2.58s 2.64s p=0.561 n=6
Total Time 14.08s (± 0.31%) 14.08s (± 0.19%) ~ 14.04s 14.11s p=0.685 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,473k (± 0.00%) 347,487k (± 0.01%) ~ 347,454k 347,502k p=0.128 n=6
Parse Time 2.47s (± 0.55%) 2.48s (± 0.59%) ~ 2.46s 2.50s p=0.742 n=6
Bind Time 0.93s (± 0.44%) 0.93s (± 0.56%) ~ 0.92s 0.93s p=0.595 n=6
Check Time 6.96s (± 0.23%) 6.99s (± 0.36%) ~ 6.94s 7.01s p=0.075 n=6
Emit Time 4.08s (± 0.62%) 4.06s (± 0.44%) ~ 4.03s 4.08s p=0.415 n=6
Total Time 14.44s (± 0.19%) 14.45s (± 0.24%) ~ 14.39s 14.49s p=0.459 n=6
TFS - node (v18.15.0, x64)
Memory used 302,852k (± 0.00%) 302,851k (± 0.01%) ~ 302,826k 302,876k p=0.810 n=6
Parse Time 1.99s (± 1.13%) 2.01s (± 0.83%) ~ 2.00s 2.04s p=0.413 n=6
Bind Time 1.00s (± 1.03%) 1.00s (± 0.41%) ~ 1.00s 1.01s p=0.924 n=6
Check Time 6.32s (± 0.13%) 6.36s (± 0.41%) +0.03s (+ 0.53%) 6.32s 6.38s p=0.048 n=6
Emit Time 3.59s (± 0.62%) 3.58s (± 0.52%) ~ 3.56s 3.60s p=0.363 n=6
Total Time 12.91s (± 0.34%) 12.95s (± 0.20%) ~ 12.92s 12.98s p=0.090 n=6
material-ui - node (v18.15.0, x64)
Memory used 511,377k (± 0.00%) 511,370k (± 0.00%) ~ 511,359k 511,377k p=1.000 n=6
Parse Time 2.66s (± 0.51%) 2.65s (± 0.72%) ~ 2.63s 2.68s p=0.357 n=6
Bind Time 1.00s (± 1.04%) 0.99s (± 1.05%) ~ 0.98s 1.01s p=0.801 n=6
Check Time 17.26s (± 0.57%) 17.28s (± 0.27%) ~ 17.23s 17.36s p=0.810 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.91s (± 0.44%) 20.92s (± 0.25%) ~ 20.86s 21.02s p=0.809 n=6
mui-docs - node (v18.15.0, x64)
Memory used 2,272,170k (± 0.00%) 2,272,171k (± 0.00%) ~ 2,272,141k 2,272,226k p=0.873 n=6
Parse Time 11.97s (± 0.55%) 11.97s (± 0.86%) ~ 11.83s 12.07s p=1.000 n=6
Bind Time 2.62s (± 0.29%) 2.62s (± 0.16%) ~ 2.61s 2.62s p=0.389 n=6
Check Time 102.27s (± 0.65%) 102.35s (± 0.67%) ~ 101.32s 103.08s p=0.936 n=6
Emit Time 0.32s (± 0.00%) 0.32s (± 0.00%) ~ 0.32s 0.32s p=1.000 n=6
Total Time 117.19s (± 0.55%) 117.26s (± 0.64%) ~ 116.09s 118.09s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,412,874k (± 0.03%) 2,412,475k (± 0.03%) ~ 2,411,306k 2,413,399k p=0.298 n=6
Parse Time 4.93s (± 0.94%) 4.91s (± 1.25%) ~ 4.87s 5.03s p=0.374 n=6
Bind Time 1.87s (± 0.66%) 1.88s (± 0.88%) ~ 1.86s 1.90s p=0.453 n=6
Check Time 33.55s (± 0.41%) 33.53s (± 0.32%) ~ 33.32s 33.62s p=0.936 n=6
Emit Time 2.69s (± 1.19%) 2.67s (± 1.45%) ~ 2.61s 2.72s p=0.261 n=6
Total Time 43.08s (± 0.38%) 43.01s (± 0.31%) ~ 42.74s 43.10s p=0.173 n=6
self-compiler - node (v18.15.0, x64)
Memory used 418,853k (± 0.01%) 418,860k (± 0.01%) ~ 418,824k 418,892k p=0.810 n=6
Parse Time 2.76s (± 3.75%) 2.78s (± 3.52%) ~ 2.65s 2.87s p=0.688 n=6
Bind Time 1.13s (± 6.57%) 1.12s (± 6.10%) ~ 1.07s 1.21s p=0.931 n=6
Check Time 15.16s (± 0.18%) 15.15s (± 0.36%) ~ 15.08s 15.23s p=0.571 n=6
Emit Time 1.13s (± 0.87%) 1.14s (± 2.03%) ~ 1.11s 1.17s p=0.412 n=6
Total Time 20.18s (± 0.27%) 20.19s (± 0.18%) ~ 20.14s 20.22s p=0.871 n=6
vscode - node (v18.15.0, x64)
Memory used 2,844,126k (± 0.00%) 2,844,056k (± 0.00%) -70k (- 0.00%) 2,844,024k 2,844,086k p=0.005 n=6
Parse Time 10.76s (± 0.14%) 10.76s (± 0.49%) ~ 10.69s 10.83s p=0.746 n=6
Bind Time 3.44s (± 0.47%) 3.44s (± 0.22%) ~ 3.43s 3.45s p=1.000 n=6
Check Time 60.47s (± 0.37%) 60.72s (± 0.40%) ~ 60.46s 61.04s p=0.109 n=6
Emit Time 16.25s (± 0.60%) 16.25s (± 0.68%) ~ 16.13s 16.40s p=1.000 n=6
Total Time 90.92s (± 0.35%) 91.17s (± 0.30%) ~ 90.87s 91.58s p=0.230 n=6
webpack - node (v18.15.0, x64)
Memory used 394,109k (± 0.02%) 394,162k (± 0.02%) ~ 394,050k 394,257k p=0.297 n=6
Parse Time 3.12s (± 1.01%) 3.12s (± 0.53%) ~ 3.10s 3.14s p=0.685 n=6
Bind Time 1.39s (± 1.34%) 1.39s (± 1.75%) ~ 1.36s 1.41s p=0.868 n=6
Check Time 14.08s (± 0.34%) 14.06s (± 0.42%) ~ 13.97s 14.13s p=0.572 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 18.58s (± 0.23%) 18.56s (± 0.42%) ~ 18.44s 18.67s p=0.688 n=6
xstate - node (v18.15.0, x64)
Memory used 513,377k (± 0.01%) 513,359k (± 0.01%) ~ 513,312k 513,435k p=0.423 n=6
Parse Time 3.27s (± 0.25%) 3.27s (± 0.23%) ~ 3.26s 3.28s p=0.729 n=6
Bind Time 1.54s (± 0.64%) 1.54s (± 0.26%) ~ 1.54s 1.55s p=0.673 n=6
Check Time 2.85s (± 0.82%) 2.86s (± 0.65%) ~ 2.84s 2.89s p=0.517 n=6
Emit Time 0.08s (± 5.21%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=0.405 n=6
Total Time 7.75s (± 0.36%) 7.76s (± 0.28%) ~ 7.74s 7.79s p=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)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,340ms (± 0.62%) 2,353ms (± 0.72%) ~ 2,331ms 2,372ms p=0.230 n=6
Req 2 - geterr 5,549ms (± 1.29%) 5,531ms (± 1.43%) ~ 5,437ms 5,603ms p=0.687 n=6
Req 3 - references 324ms (± 1.34%) 326ms (± 1.54%) ~ 320ms 331ms p=1.000 n=6
Req 4 - navto 276ms (± 1.12%) 276ms (± 1.01%) ~ 273ms 279ms p=0.625 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 85ms (± 9.67%) 88ms (± 6.65%) ~ 80ms 95ms p=0.464 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,481ms (± 0.54%) 2,494ms (± 0.58%) ~ 2,476ms 2,512ms p=0.092 n=6
Req 2 - geterr 4,142ms (± 1.48%) 4,165ms (± 1.76%) ~ 4,114ms 4,265ms p=0.688 n=6
Req 3 - references 336ms (± 1.56%) 337ms (± 1.44%) ~ 331ms 343ms p=0.682 n=6
Req 4 - navto 285ms (± 0.44%) 284ms (± 0.57%) ~ 282ms 286ms p=0.504 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 88ms (± 5.34%) 87ms (± 5.25%) ~ 78ms 90ms p=0.718 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,612ms (± 0.36%) 2,612ms (± 0.60%) ~ 2,596ms 2,637ms p=1.000 n=6
Req 2 - geterr 1,757ms (± 2.54%) 1,739ms (± 3.61%) ~ 1,650ms 1,797ms p=0.688 n=6
Req 3 - references 117ms (± 9.23%) 117ms (± 9.67%) ~ 107ms 129ms p=0.806 n=6
Req 4 - navto 370ms (± 0.85%) 371ms (± 0.26%) ~ 370ms 372ms p=0.558 n=6
Req 5 - completionInfo count 2,078 (± 0.00%) 2,078 (± 0.00%) ~ 2,078 2,078 p=1.000 n=6
Req 5 - completionInfo 312ms (± 1.11%) 313ms (± 1.41%) ~ 307ms 316ms p=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)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 153.95ms (± 0.21%) 153.61ms (± 0.19%) -0.35ms (- 0.23%) 152.48ms 157.45ms p=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 229.84ms (± 0.16%) 229.60ms (± 0.18%) -0.24ms (- 0.11%) 228.11ms 236.78ms p=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 231.22ms (± 0.19%) 231.17ms (± 0.17%) ~ 229.64ms 234.44ms p=0.518 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 231.00ms (± 0.17%) 231.06ms (± 0.16%) ~ 229.73ms 234.85ms p=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)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@gabritto gabritto merged commit 29c0024 into microsoft:main Feb 16, 2024
19 checks passed
@DavidArchibald
Copy link

DavidArchibald commented Feb 22, 2024

This is also observable with something like this:

type SomeCallback<Args extends readonly any[]> = (...args: Args) => void;

function call<Callback extends SomeCallback<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.

@Andarist Andarist deleted the fix/any-rest branch February 22, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR 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