GeezerVison is showing github.com — Fix issues + Support template literal types as discriminants by ahejlsberg · Pull Request #46137 · microsoft/TypeScript
Conversation
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
c69-addepar, ShanTulshi, alitaheri, martinfrancois, anuraghazra, pdx-daniel, and bilalq reacted with heart emoji
|
|
|
|
|
// Repro from #46045
|
|
|
|
|
|
export type Action =
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to remove the export from this and the other line to keep around the declaration emit in the test.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
const targetEnd = target.texts[target.texts.length - 1];
|
|
|
const startLen = Math.min(sourceStart.length, targetStart.length);
|
|
|
const endLen = Math.min(sourceEnd.length, targetEnd.length);
|
|
|
return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this flag foo-${boolean} and foo-${number} as possibly related? We still need to make sure the holes relate when this returns True, no?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it'll flag them as possibly related. Or, rather, not flag them as definitely unrelated. We could potentially check the placeholders that immediately follow identical prefix texts or immediately precede identical suffix texts, but honestly there's very little gained from it. In fact, probably only the boolean vs. number disqualification. I think what is here already is sufficient, and it impacts whether we flag operands as non-overlapping, which isn't super critical to get 100% right.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
craigphicks reacted with thumbs up emoji
|
|
|
|
|
// Repro from #46125
|
|
|
|
|
|
function ff1<T extends string>(x: `foo-${string}`, y: `${string}-bar`, z: `baz-${string}`) {
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before I forget, can we also get a copy of this test with a signature like
function ff1<T extends string>(x: `foo-${T}`, y: `${T}-bar`, z: `baz-${T}`) {
? I figure it should behave the same, but, y'know, coverage. Maybe it can just be more cases on this signature, since it already has a generic parameter for some reason~
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!
Here they are:
Comparison Report - main..46137
| Metric |
main |
46137 |
Delta |
Best |
Worst |
| Angular - node (v10.16.3, x64) |
| Memory used |
354,154k (± 0.02%) |
354,131k (± 0.02%) |
-23k (- 0.01%) |
354,015k |
354,332k |
| Parse Time |
1.94s (± 0.49%) |
1.94s (± 0.37%) |
+0.01s (+ 0.36%) |
1.93s |
1.96s |
| Bind Time |
0.84s (± 0.62%) |
0.84s (± 0.98%) |
+0.00s (+ 0.36%) |
0.83s |
0.86s |
| Check Time |
5.46s (± 0.46%) |
5.47s (± 0.50%) |
+0.00s (+ 0.07%) |
5.39s |
5.52s |
| Emit Time |
5.82s (± 0.33%) |
5.86s (± 0.69%) |
+0.04s (+ 0.67%) |
5.78s |
5.96s |
| Total Time |
14.06s (± 0.25%) |
14.12s (± 0.33%) |
+0.05s (+ 0.38%) |
14.01s |
14.23s |
| Compiler-Unions - node (v10.16.3, x64) |
| Memory used |
203,944k (± 0.02%) |
203,852k (± 0.04%) |
-91k (- 0.04%) |
203,701k |
203,992k |
| Parse Time |
0.78s (± 0.97%) |
0.79s (± 1.13%) |
+0.00s (+ 0.26%) |
0.77s |
0.81s |
| Bind Time |
0.52s (± 1.18%) |
0.52s (± 1.28%) |
+0.00s (+ 0.38%) |
0.51s |
0.54s |
| Check Time |
7.94s (± 0.70%) |
7.91s (± 0.57%) |
-0.02s (- 0.29%) |
7.82s |
8.06s |
| Emit Time |
2.47s (± 0.81%) |
2.46s (± 0.81%) |
-0.01s (- 0.45%) |
2.41s |
2.50s |
| Total Time |
11.71s (± 0.57%) |
11.68s (± 0.42%) |
-0.03s (- 0.26%) |
11.60s |
11.82s |
| Monaco - node (v10.16.3, x64) |
| Memory used |
342,054k (± 0.03%) |
341,996k (± 0.02%) |
-58k (- 0.02%) |
341,871k |
342,258k |
| Parse Time |
1.48s (± 0.51%) |
1.47s (± 0.71%) |
-0.01s (- 0.34%) |
1.44s |
1.49s |
| Bind Time |
0.75s (± 0.40%) |
0.75s (± 0.77%) |
-0.00s (- 0.27%) |
0.74s |
0.76s |
| Check Time |
5.45s (± 0.65%) |
5.44s (± 0.63%) |
-0.01s (- 0.17%) |
5.38s |
5.53s |
| Emit Time |
3.18s (± 0.69%) |
3.19s (± 0.96%) |
+0.00s (+ 0.13%) |
3.10s |
3.25s |
| Total Time |
10.86s (± 0.33%) |
10.85s (± 0.36%) |
-0.01s (- 0.11%) |
10.76s |
10.94s |
| TFS - node (v10.16.3, x64) |
| Memory used |
304,663k (± 0.02%) |
304,672k (± 0.02%) |
+9k (+ 0.00%) |
304,503k |
304,836k |
| Parse Time |
1.19s (± 0.50%) |
1.19s (± 0.44%) |
-0.00s (- 0.25%) |
1.18s |
1.20s |
| Bind Time |
0.71s (± 0.81%) |
0.71s (± 0.78%) |
-0.00s (- 0.28%) |
0.69s |
0.72s |
| Check Time |
4.99s (± 0.66%) |
4.96s (± 0.46%) |
-0.03s (- 0.56%) |
4.88s |
5.00s |
| Emit Time |
3.33s (± 1.65%) |
3.33s (± 0.88%) |
-0.01s (- 0.21%) |
3.26s |
3.40s |
| Total Time |
10.22s (± 0.61%) |
10.18s (± 0.42%) |
-0.04s (- 0.40%) |
10.05s |
10.26s |
| material-ui - node (v10.16.3, x64) |
| Memory used |
472,240k (± 0.02%) |
472,270k (± 0.02%) |
+30k (+ 0.01%) |
472,053k |
472,392k |
| Parse Time |
1.77s (± 0.38%) |
1.76s (± 0.50%) |
-0.00s (- 0.23%) |
1.75s |
1.79s |
| Bind Time |
0.66s (± 0.61%) |
0.66s (± 0.55%) |
-0.00s (- 0.46%) |
0.65s |
0.66s |
| Check Time |
14.41s (± 0.65%) |
14.38s (± 0.71%) |
-0.03s (- 0.18%) |
14.25s |
14.68s |
| Emit Time |
0.00s (± 0.00%) |
0.00s (± 0.00%) |
0.00s ( NaN%) |
0.00s |
0.00s |
| Total Time |
16.83s (± 0.59%) |
16.80s (± 0.64%) |
-0.03s (- 0.17%) |
16.66s |
17.12s |
| Angular - node (v12.1.0, x64) |
| Memory used |
332,038k (± 0.03%) |
331,993k (± 0.02%) |
-45k (- 0.01%) |
331,833k |
332,156k |
| Parse Time |
1.93s (± 0.78%) |
1.92s (± 0.45%) |
-0.00s (- 0.21%) |
1.90s |
1.93s |
| Bind Time |
0.82s (± 0.82%) |
0.81s (± 0.90%) |
-0.01s (- 0.61%) |
0.80s |
0.83s |
| Check Time |
5.30s (± 0.37%) |
5.30s (± 0.56%) |
-0.00s (- 0.06%) |
5.23s |
5.36s |
| Emit Time |
6.09s (± 0.61%) |
6.14s (± 0.89%) |
+0.04s (+ 0.72%) |
6.06s |
6.29s |
| Total Time |
14.14s (± 0.39%) |
14.18s (± 0.37%) |
+0.03s (+ 0.23%) |
14.03s |
14.30s |
| Compiler-Unions - node (v12.1.0, x64) |
| Memory used |
191,331k (± 0.11%) |
191,264k (± 0.12%) |
-66k (- 0.03%) |
190,408k |
191,506k |
| Parse Time |
0.78s (± 0.85%) |
0.78s (± 0.61%) |
-0.00s (- 0.38%) |
0.77s |
0.79s |
| Bind Time |
0.53s (± 0.98%) |
0.53s (± 0.92%) |
+0.00s (+ 0.95%) |
0.52s |
0.54s |
| Check Time |
7.43s (± 0.66%) |
7.39s (± 0.75%) |
-0.04s (- 0.54%) |
7.30s |
7.51s |
| Emit Time |
2.46s (± 1.03%) |
2.48s (± 0.95%) |
+0.02s (+ 0.69%) |
2.43s |
2.54s |
| Total Time |
11.20s (± 0.61%) |
11.18s (± 0.62%) |
-0.02s (- 0.21%) |
11.06s |
11.33s |
| Monaco - node (v12.1.0, x64) |
| Memory used |
325,116k (± 0.02%) |
325,088k (± 0.02%) |
-28k (- 0.01%) |
324,925k |
325,220k |
| Parse Time |
1.45s (± 0.47%) |
1.47s (± 0.81%) |
+0.01s (+ 0.89%) |
1.44s |
1.49s |
| Bind Time |
0.73s (± 0.47%) |
0.73s (± 1.06%) |
+0.00s (+ 0.55%) |
0.72s |
0.75s |
| Check Time |
5.35s (± 0.65%) |
5.31s (± 0.33%) |
-0.03s (- 0.58%) |
5.27s |
5.35s |
| Emit Time |
3.20s (± 0.70%) |
3.17s (± 0.65%) |
-0.03s (- 0.81%) |
3.14s |
3.22s |
| Total Time |
10.73s (± 0.46%) |
10.68s (± 0.36%) |
-0.04s (- 0.39%) |
10.60s |
10.77s |
| TFS - node (v12.1.0, x64) |
| Memory used |
289,416k (± 0.02%) |
289,429k (± 0.02%) |
+14k (+ 0.00%) |
289,295k |
289,617k |
| Parse Time |
1.21s (± 0.71%) |
1.21s (± 0.62%) |
+0.00s (+ 0.08%) |
1.20s |
1.23s |
| Bind Time |
0.69s (± 0.69%) |
0.69s (± 0.81%) |
+0.00s (+ 0.15%) |
0.68s |
0.70s |
| Check Time |
4.90s (± 0.26%) |
4.89s (± 0.31%) |
-0.02s (- 0.33%) |
4.86s |
4.94s |
| Emit Time |
3.39s (± 0.85%) |
3.38s (± 0.92%) |
-0.01s (- 0.35%) |
3.31s |
3.45s |
| Total Time |
10.20s (± 0.33%) |
10.17s (± 0.37%) |
-0.03s (- 0.25%) |
10.08s |
10.23s |
| material-ui - node (v12.1.0, x64) |
| Memory used |
450,955k (± 0.02%) |
450,742k (± 0.08%) |
-213k (- 0.05%) |
449,797k |
451,114k |
| Parse Time |
1.77s (± 0.47%) |
1.77s (± 0.57%) |
0.00s ( 0.00%) |
1.75s |
1.80s |
| Bind Time |
0.64s (± 1.32%) |
0.64s (± 1.25%) |
+0.00s (+ 0.16%) |
0.62s |
0.66s |
| Check Time |
13.05s (± 0.49%) |
13.00s (± 0.68%) |
-0.05s (- 0.38%) |
12.84s |
13.26s |
| Emit Time |
0.00s (± 0.00%) |
0.00s (± 0.00%) |
0.00s ( NaN%) |
0.00s |
0.00s |
| Total Time |
15.47s (± 0.45%) |
15.42s (± 0.58%) |
-0.05s (- 0.32%) |
15.26s |
15.67s |
| Angular - node (v14.15.1, x64) |
| Memory used |
330,452k (± 0.01%) |
330,452k (± 0.01%) |
-1k (- 0.00%) |
330,419k |
330,494k |
| Parse Time |
1.95s (± 0.67%) |
1.94s (± 0.49%) |
-0.00s (- 0.26%) |
1.93s |
1.97s |
| Bind Time |
0.86s (± 0.65%) |
0.86s (± 0.84%) |
+0.00s (+ 0.47%) |
0.85s |
0.88s |
| Check Time |
5.35s (± 0.56%) |
5.33s (± 0.58%) |
-0.02s (- 0.36%) |
5.26s |
5.40s |
| Emit Time |
6.22s (± 0.74%) |
6.20s (± 0.70%) |
-0.02s (- 0.32%) |
6.10s |
6.30s |
| Total Time |
14.38s (± 0.51%) |
14.33s (± 0.54%) |
-0.04s (- 0.29%) |
14.19s |
14.48s |
| Compiler-Unions - node (v14.15.1, x64) |
| Memory used |
193,187k (± 0.01%) |
192,529k (± 0.49%) |
-659k (- 0.34%) |
189,961k |
193,210k |
| Parse Time |
0.81s (± 0.64%) |
0.81s (± 0.90%) |
-0.00s (- 0.37%) |
0.80s |
0.83s |
| Bind Time |
0.56s (± 0.65%) |
0.55s (± 0.40%) |
-0.01s (- 0.90%) |
0.55s |
0.56s |
| Check Time |
7.55s (± 0.73%) |
7.49s (± 0.37%) |
-0.07s (- 0.86%) |
7.41s |
7.55s |
| Emit Time |
2.41s (± 0.48%) |
2.44s (± 1.14%) |
+0.04s (+ 1.45%) |
2.39s |
2.52s |
| Total Time |
11.32s (± 0.50%) |
11.29s (± 0.33%) |
-0.03s (- 0.26%) |
11.21s |
11.39s |
| Monaco - node (v14.15.1, x64) |
| Memory used |
323,989k (± 0.00%) |
323,996k (± 0.01%) |
+7k (+ 0.00%) |
323,956k |
324,046k |
| Parse Time |
1.51s (± 0.51%) |
1.51s (± 0.77%) |
-0.00s (- 0.20%) |
1.48s |
1.53s |
| Bind Time |
0.76s (± 0.48%) |
0.75s (± 0.79%) |
-0.00s (- 0.26%) |
0.74s |
0.77s |
| Check Time |
5.30s (± 0.59%) |
5.30s (± 0.49%) |
+0.00s (+ 0.02%) |
5.25s |
5.39s |
| Emit Time |
3.21s (± 0.87%) |
3.22s (± 0.81%) |
+0.02s (+ 0.50%) |
3.18s |
3.29s |
| Total Time |
10.78s (± 0.45%) |
10.79s (± 0.39%) |
+0.01s (+ 0.13%) |
10.69s |
10.89s |
| TFS - node (v14.15.1, x64) |
| Memory used |
288,334k (± 0.01%) |
288,337k (± 0.01%) |
+3k (+ 0.00%) |
288,294k |
288,407k |
| Parse Time |
1.24s (± 0.47%) |
1.23s (± 0.24%) |
-0.01s (- 0.73%) |
1.22s |
1.23s |
| Bind Time |
0.73s (± 0.84%) |
0.73s (± 0.55%) |
+0.00s (+ 0.00%) |
0.72s |
0.74s |
| Check Time |
4.91s (± 0.38%) |
4.93s (± 0.39%) |
+0.01s (+ 0.28%) |
4.88s |
4.97s |
| Emit Time |
3.48s (± 0.52%) |
3.49s (± 0.87%) |
+0.01s (+ 0.43%) |
3.43s |
3.56s |
| Total Time |
10.36s (± 0.25%) |
10.38s (± 0.31%) |
+0.02s (+ 0.19%) |
10.31s |
10.44s |
| material-ui - node (v14.15.1, x64) |
| Memory used |
448,958k (± 0.09%) |
449,300k (± 0.00%) |
+342k (+ 0.08%) |
449,275k |
449,351k |
| Parse Time |
1.82s (± 0.61%) |
1.81s (± 0.56%) |
-0.01s (- 0.49%) |
1.79s |
1.84s |
| Bind Time |
0.68s (± 1.03%) |
0.68s (± 0.69%) |
-0.00s (- 0.15%) |
0.67s |
0.69s |
| Check Time |
13.23s (± 1.18%) |
13.13s (± 0.55%) |
-0.10s (- 0.73%) |
12.97s |
13.36s |
| Emit Time |
0.00s (± 0.00%) |
0.00s (± 0.00%) |
0.00s ( NaN%) |
0.00s |
0.00s |
| Total Time |
15.73s (± 1.04%) |
15.63s (± 0.52%) |
-0.11s (- 0.67%) |
15.45s |
15.89s |
System
| Machine Name | ts-ci-ubuntu |
| Platform | linux 4.4.0-210-generic |
| Architecture | x64 |
| Available Memory | 16 GB |
| Available Memory | 8 GB |
| CPUs | 4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz |
Hosts
- node (v10.16.3, x64)
- node (v12.1.0, x64)
- node (v14.15.1, x64)
Scenarios
- Angular - node (v10.16.3, x64)
- Angular - node (v12.1.0, x64)
- Angular - node (v14.15.1, x64)
- Compiler-Unions - node (v10.16.3, x64)
- Compiler-Unions - node (v12.1.0, x64)
- Compiler-Unions - node (v14.15.1, x64)
- Monaco - node (v10.16.3, x64)
- Monaco - node (v12.1.0, x64)
- Monaco - node (v14.15.1, x64)
- TFS - node (v10.16.3, x64)
- TFS - node (v12.1.0, x64)
- TFS - node (v14.15.1, x64)
- material-ui - node (v10.16.3, x64)
- material-ui - node (v12.1.0, x64)
- material-ui - node (v14.15.1, x64)
| Benchmark |
Name |
Iterations |
| Current |
46137 |
10 |
| Baseline |
main |
10 |
Developer Information:Download Benchmark
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Tests look clean, perf is slightly improved if anything. I think this one is good to go!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Great! But will buitin string methods support this? For now, I'm forced to use these standalone functions:
const startsWith = <T extends string>(str: string, search: T): str is `${T}${string}` => str.startsWith(search);
const endsWith = <T extends string>(str: string, search: T): str is `${string}${T}` => str.endsWith(search);
const includes = <T extends string>(str: string, search: T): str is `${string}${T}${string}` => str.includes(search);
|
Bloemendaal and cr7pt0gr4ph7 reacted with thumbs up emoji
tonkotsuboy reacted with hooray emoji
All reactions
-
👍
2 reactions
-
🎉
1 reaction
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|