Skip to content

Conversation

Andarist
Copy link
Contributor

fixes #55847

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 25, 2023
@jakebailey
Copy link
Member

This looks good to me (having touched this recently), but:

@typescript-bot test top200
@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 Sep 25, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 9f56c7f. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 9f56c7f. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 9f56c7f. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2023

Hey @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/157926/artifacts?artifactName=tgz&fileId=1FA9231F21A39E8A58C48819B07BF08D74C3576968C20B4DB594B040867ABB8802&fileName=/typescript-5.3.0-insiders.20230925.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/[email protected]".;

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/55856/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 2 instances of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 294,974k (± 0.01%) 294,952k (± 0.01%) ~ 294,908k 294,991k p=0.230 n=6
Parse Time 2.61s (± 0.32%) 2.61s (± 0.71%) ~ 2.60s 2.65s p=0.607 n=6
Bind Time 0.84s (± 1.23%) 0.83s (± 0.98%) ~ 0.83s 0.85s p=0.595 n=6
Check Time 8.06s (± 0.35%) 8.06s (± 0.24%) ~ 8.03s 8.08s p=1.000 n=6
Emit Time 7.04s (± 0.45%) 7.06s (± 0.53%) ~ 7.00s 7.09s p=0.260 n=6
Total Time 18.56s (± 0.22%) 18.57s (± 0.24%) ~ 18.51s 18.63s p=0.748 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,129k (± 1.25%) 191,670k (± 1.23%) ~ 190,687k 196,485k p=0.173 n=6
Parse Time 1.34s (± 0.61%) 1.35s (± 0.86%) +0.01s (+ 1.12%) 1.34s 1.37s p=0.039 n=6
Bind Time 0.73s (± 0.00%) 0.73s (± 0.00%) ~ 0.73s 0.73s p=1.000 n=6
Check Time 9.14s (± 0.72%) 9.12s (± 0.59%) ~ 9.03s 9.18s p=0.873 n=6
Emit Time 2.63s (± 0.56%) 2.63s (± 0.40%) ~ 2.61s 2.64s p=0.805 n=6
Total Time 13.84s (± 0.37%) 13.83s (± 0.43%) ~ 13.72s 13.89s p=1.000 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,219k (± 0.01%) 347,216k (± 0.01%) ~ 347,173k 347,248k p=0.873 n=6
Parse Time 2.45s (± 0.42%) 2.46s (± 0.36%) ~ 2.45s 2.47s p=0.273 n=6
Bind Time 0.94s (± 0.00%) 0.94s (± 0.00%) ~ 0.94s 0.94s p=1.000 n=6
Check Time 6.88s (± 0.39%) 6.85s (± 0.43%) ~ 6.80s 6.88s p=0.141 n=6
Emit Time 4.02s (± 0.24%) 4.02s (± 0.49%) ~ 3.99s 4.04s p=0.802 n=6
Total Time 14.29s (± 0.25%) 14.27s (± 0.18%) ~ 14.24s 14.30s p=0.168 n=6
TFS - node (v18.15.0, x64)
Memory used 302,495k (± 0.01%) 302,488k (± 0.01%) ~ 302,468k 302,523k p=0.297 n=6
Parse Time 2.01s (± 0.97%) 2.01s (± 0.68%) ~ 1.99s 2.03s p=0.567 n=6
Bind Time 1.00s (± 0.41%) 1.01s (± 1.32%) ~ 1.00s 1.03s p=0.462 n=6
Check Time 6.26s (± 0.34%) 6.24s (± 0.49%) -0.02s (- 0.40%) 6.22s 6.30s p=0.048 n=6
Emit Time 3.55s (± 1.08%) 3.52s (± 0.80%) ~ 3.49s 3.57s p=0.372 n=6
Total Time 12.82s (± 0.55%) 12.78s (± 0.27%) ~ 12.74s 12.83s p=0.466 n=6
material-ui - node (v18.15.0, x64)
Memory used 470,449k (± 0.00%) 470,450k (± 0.00%) ~ 470,427k 470,478k p=0.936 n=6
Parse Time 2.56s (± 0.35%) 2.57s (± 0.49%) ~ 2.56s 2.59s p=0.209 n=6
Bind Time 0.99s (± 0.55%) 0.99s (± 0.82%) ~ 0.98s 1.00s p=0.859 n=6
Check Time 16.60s (± 0.19%) 16.59s (± 0.60%) ~ 16.50s 16.73s p=0.422 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.16s (± 0.17%) 20.15s (± 0.53%) ~ 20.05s 20.31s p=0.520 n=6
xstate - node (v18.15.0, x64)
Memory used 512,556k (± 0.02%) 512,514k (± 0.01%) ~ 512,441k 512,575k p=0.378 n=6
Parse Time 3.27s (± 0.12%) 3.27s (± 0.26%) ~ 3.26s 3.28s p=0.285 n=6
Bind Time 1.55s (± 0.33%) 1.55s (± 0.48%) ~ 1.54s 1.56s p=0.241 n=6
Check Time 2.83s (± 0.49%) 2.84s (± 0.79%) ~ 2.80s 2.86s p=0.745 n=6
Emit Time 0.08s (± 4.99%) 0.08s (± 9.21%) ~ 0.07s 0.09s p=1.000 n=6
Total Time 7.73s (± 0.19%) 7.73s (± 0.26%) ~ 7.71s 7.75s p=0.809 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)
  • 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,350ms (± 0.93%) 2,350ms (± 1.24%) ~ 2,324ms 2,398ms p=0.748 n=6
Req 2 - geterr 5,371ms (± 1.62%) 5,375ms (± 1.52%) ~ 5,257ms 5,448ms p=0.810 n=6
Req 3 - references 329ms (± 1.50%) 327ms (± 0.57%) ~ 325ms 330ms p=0.371 n=6
Req 4 - navto 275ms (± 0.78%) 276ms (± 1.11%) ~ 272ms 281ms p=1.000 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 84ms (± 8.13%) 86ms (± 7.12%) ~ 76ms 90ms p=0.652 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,461ms (± 1.60%) 2,466ms (± 1.18%) ~ 2,421ms 2,495ms p=1.000 n=6
Req 2 - geterr 4,153ms (± 1.94%) 4,141ms (± 1.92%) ~ 4,062ms 4,231ms p=0.423 n=6
Req 3 - references 336ms (± 1.03%) 338ms (± 1.28%) ~ 333ms 343ms p=0.328 n=6
Req 4 - navto 283ms (± 0.43%) 283ms (± 0.18%) ~ 283ms 284ms p=0.351 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 77ms (± 7.19%) 79ms (± 7.50%) ~ 75ms 87ms p=0.285 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,596ms (± 0.41%) 2,600ms (± 0.44%) ~ 2,579ms 2,608ms p=0.260 n=6
Req 2 - geterr 1,706ms (± 1.55%) 1,674ms (± 1.68%) ~ 1,640ms 1,721ms p=0.093 n=6
Req 3 - references 121ms (± 6.58%) 113ms (± 8.62%) ~ 106ms 126ms p=0.106 n=6
Req 4 - navto 360ms (± 0.76%) 360ms (± 0.49%) ~ 358ms 363ms p=0.802 n=6
Req 5 - completionInfo count 2,071 (± 0.00%) 2,071 (± 0.00%) ~ 2,071 2,071 p=1.000 n=6
Req 5 - completionInfo 306ms (± 1.62%) 305ms (± 1.90%) ~ 297ms 313ms p=0.748 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 151.89ms (± 0.15%) 151.98ms (± 0.18%) +0.09ms (+ 0.06%) 150.85ms 155.36ms p=0.005 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 227.62ms (± 0.18%) 227.38ms (± 0.15%) -0.23ms (- 0.10%) 225.78ms 232.51ms p=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 229.09ms (± 0.19%) 229.27ms (± 0.18%) +0.18ms (+ 0.08%) 227.65ms 235.68ms p=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 228.88ms (± 0.22%) 228.58ms (± 0.15%) -0.30ms (- 0.13%) 227.07ms 234.10ms p=0.000 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

@typescript-bot
Copy link
Collaborator

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@sankantsu
Copy link

sankantsu commented Sep 26, 2023

Thank you for creating PR!

It seems still fails in some (very artificial) examples...

type E<S> = Lowercase<`f${S & string}` & `${S & string}f`>
>E : Lowercase<`f${S & string}` & `${S & string}f`>

type F = E<""> extends "f" ? 1 : 0
>F : 1

type G<S> = E<S> extends "f" ? 1 : 0
>G : 0

let x5: G<""> = 1;
>x5 : 0
>1 : 1

E<""> is "f", so G<""> should be 1

Playground link (v5.0.4)

@Andarist
Copy link
Contributor Author

Ah, ye - I see why it might fail. I'll try to improve the fix in a moment to handle more crazy scenarios like this recursively.

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 27, 2023
function isPatternLiteralPlaceholderType(type: Type): boolean {
function isPatternLiteralPlaceholderType(type: Type, ignoreGenericIntersections = false): boolean {
if (type.flags & TypeFlags.Intersection) {
return some((type as IntersectionType).types, t => !!(t.flags & (TypeFlags.Literal | TypeFlags.Null | TypeFlags.Undefined)) || isPatternLiteralPlaceholderType(t));
Copy link
Member

Choose a reason for hiding this comment

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

I think this entire fix can be simplified to simply adding a check that the type isn't generic:

return !isGenericType(type) && some(...);

Generic types should never be classified as placeholders since upon instantiation they may become something completely different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, that's cool! Thanks for the tip. I was worried that addSpans would fail if I did something like this. It seems that (somewhat confusingly) isGenericIndexType already returns true for an intersection like this so addSpans is covered.

@jakebailey
Copy link
Member

LGTM but just going to double check:

@typescript-bot test top200
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 29, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 5d29c23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 29, 2023

Heya @jakebailey, I've started to run the tsc-only perf test suite on this PR at 5d29c23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 29, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at 5d29c23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 29, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at 5d29c23. 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:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 294,998k (± 0.01%) 295,000k (± 0.01%) ~ 294,951k 295,054k p=1.000 n=6
Parse Time 2.63s (± 0.42%) 2.63s (± 0.66%) ~ 2.60s 2.65s p=0.365 n=6
Bind Time 0.84s (± 1.06%) 0.84s (± 1.06%) ~ 0.83s 0.85s p=1.000 n=6
Check Time 8.08s (± 0.36%) 8.06s (± 0.12%) ~ 8.05s 8.07s p=0.289 n=6
Emit Time 7.03s (± 0.25%) 7.04s (± 0.29%) ~ 7.01s 7.07s p=0.935 n=6
Total Time 18.58s (± 0.17%) 18.57s (± 0.12%) ~ 18.55s 18.61s p=0.747 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,089k (± 1.24%) 192,597k (± 1.56%) ~ 190,606k 196,482k p=0.810 n=6
Parse Time 1.35s (± 1.11%) 1.35s (± 0.87%) ~ 1.34s 1.37s p=0.730 n=6
Bind Time 0.73s (± 0.00%) 0.73s (± 0.00%) ~ 0.73s 0.73s p=1.000 n=6
Check Time 9.21s (± 0.65%) 9.18s (± 0.17%) ~ 9.15s 9.19s p=0.683 n=6
Emit Time 2.62s (± 0.54%) 2.63s (± 0.62%) ~ 2.61s 2.65s p=0.568 n=6
Total Time 13.92s (± 0.44%) 13.88s (± 0.18%) ~ 13.85s 13.91s p=0.293 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,239k (± 0.00%) 347,226k (± 0.01%) ~ 347,204k 347,248k p=0.229 n=6
Parse Time 2.45s (± 0.36%) 2.46s (± 0.42%) ~ 2.44s 2.47s p=0.273 n=6
Bind Time 0.94s (± 0.43%) 0.94s (± 0.00%) ~ 0.94s 0.94s p=0.405 n=6
Check Time 6.89s (± 0.51%) 6.88s (± 0.50%) ~ 6.84s 6.93s p=0.687 n=6
Emit Time 4.03s (± 0.38%) 4.03s (± 0.37%) ~ 4.01s 4.05s p=0.801 n=6
Total Time 14.31s (± 0.26%) 14.30s (± 0.28%) ~ 14.26s 14.35s p=0.466 n=6
TFS - node (v18.15.0, x64)
Memory used 302,529k (± 0.01%) 302,550k (± 0.01%) ~ 302,519k 302,582k p=0.336 n=6
Parse Time 2.00s (± 1.32%) 2.00s (± 0.82%) ~ 1.98s 2.02s p=0.807 n=6
Bind Time 1.01s (± 1.08%) 1.01s (± 0.51%) ~ 1.00s 1.01s p=0.670 n=6
Check Time 6.27s (± 0.60%) 6.26s (± 0.52%) ~ 6.20s 6.29s p=0.872 n=6
Emit Time 3.54s (± 0.85%) 3.55s (± 0.96%) ~ 3.51s 3.59s p=0.461 n=6
Total Time 12.82s (± 0.31%) 12.80s (± 0.50%) ~ 12.74s 12.89s p=0.520 n=6
material-ui - node (v18.15.0, x64)
Memory used 470,489k (± 0.00%) 470,484k (± 0.00%) ~ 470,471k 470,503k p=0.810 n=6
Parse Time 2.57s (± 0.38%) 2.57s (± 0.52%) ~ 2.55s 2.59s p=0.858 n=6
Bind Time 0.99s (± 1.64%) 1.00s (± 0.75%) ~ 0.99s 1.01s p=0.741 n=6
Check Time 16.56s (± 0.32%) 16.64s (± 0.48%) ~ 16.56s 16.78s p=0.066 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.12s (± 0.30%) 20.21s (± 0.34%) ~ 20.15s 20.33s p=0.108 n=6
xstate - node (v18.15.0, x64)
Memory used 512,548k (± 0.02%) 512,580k (± 0.02%) ~ 512,495k 512,729k p=0.378 n=6
Parse Time 3.26s (± 0.41%) 3.27s (± 0.30%) ~ 3.25s 3.28s p=0.340 n=6
Bind Time 1.55s (± 0.33%) 1.55s (± 0.33%) ~ 1.54s 1.55s p=1.000 n=6
Check Time 2.83s (± 1.15%) 2.85s (± 1.03%) ~ 2.82s 2.90s p=0.293 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 5.21%) ~ 0.07s 0.08s p=0.405 n=6
Total Time 7.72s (± 0.55%) 7.74s (± 0.32%) ~ 7.72s 7.79s p=0.225 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)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/55856/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 2 instances of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@sandersn
Copy link
Member

@jakebailey @ahejlsberg is this a fix intended for 5.3, or should we wait until 5.4?

@jakebailey
Copy link
Member

Probably meant for 5.3, not sure why we didn't merge it as we both approved

@sandersn sandersn merged commit 41ebfbf into microsoft:main Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Intrinsic string mapping type with type parameters is incorrectly resolved in conditional types

6 participants