Skip to content

Allow intersections to be used as valid types for template literal placeholders - #54188

Merged
Gabriela Araujo Britto (gabritto) merged 3 commits into
microsoft:mainfrom
Andarist:fix/intersections-as-valid-types-for-template-literal-placeholders
Aug 10, 2023
Merged

Allow intersections to be used as valid types for template literal placeholders#54188
Gabriela Araujo Britto (gabritto) merged 3 commits into
microsoft:mainfrom
Andarist:fix/intersections-as-valid-types-for-template-literal-placeholders

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

@gabritto

Copy link
Copy Markdown
Member

Couple of things:

  • There should be a fourslash test asserting that "dataDowncast" and other literals are suggested, since that's what the original issue is about.
  • We're trying to add an official way to support this pattern of suggesting specific string literals even when the type of something is string so we can at some point stop supporting the string & {} workaround, so I'm not entirely sure we want to add even more code to support this.

@sandersnNathan Shively-Sanders (sandersn) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 24, 2023
…valid-types-for-template-literal-placeholders
# Conflicts:
#	tests/baselines/reference/templateLiteralTypesPatterns.errors.txt
@Andarist

Copy link
Copy Markdown
ContributorAuthor

There should be a fourslash test asserting that "dataDowncast" and other literals are suggested, since that's what the original issue is about.

done

We're trying to add an official way to support this pattern of suggesting specific string literals even when the type of something is string so we can at some point stop supporting the string & {} workaround, so I'm not entirely sure we want to add even more code to support this.

Reading through some of the recent design notes (here)... it's still unclear if/when/how the team is going to pick up this. This PR though doesn't introduce a lot of extra support for those "special intersections" - it fixes assignability issues when they are involved. This is a clear bug from the assignability PoV:

functionconversionTest(groupName: |"downcast"|"dataDowncast"|"editingDowncast"| `${string&{}}Downcast`){}conversionTest("testDowncast");// error but should be OK

Some other cases are improved with it as well, like this one:

functionfoo(str: `${`a${string}` & `${string}a`}Test`){}foo("abaTest");// error but should be OK

@Andarist
Mateusz Burzyński (Andarist)force-pushed the fix/intersections-as-valid-types-for-template-literal-placeholders branch from 0a12f3e to f5f1403CompareJuly 28, 2023 22:33
@gabritto

This comment was marked as duplicate.

@gabritto

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based top-repos suite (tsserver) on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the extended test suite on this PR at f5f1403. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based user code test suite (tsserver) on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the perf test suite on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the parallelized Definitely Typed test suite on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based top-repos suite on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based user code test suite on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@gabritto

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the tarball bundle task on this PR at f5f1403. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 2, 2023

Copy link
Copy Markdown
Contributor

Hey Gabriela Araujo Britto (@gabritto), 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/156146/artifacts?artifactName=tgz&fileId=B4E808AEF0B5E588AAC7808FD4E37C5A125444385FBC9FA7E0FF9A8CF035B6F702&fileName=/typescript-5.2.0-insiders.20230802.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.2.0-pr-54188-13".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the user test suite comparing main and refs/pull/54188/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the user test suite comparing main and refs/pull/54188/merge:

There were infrastructure failures potentially unrelated to your change:

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

Otherwise...

Something interesting changed - please have a look.

Details

rxjs-src

/mnt/ts_downloads/rxjs-src/build.sh

  • [NEW] error TS2428: All declarations of 'WeakMap' must have identical type parameters.
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54188/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
  • [MISSING] error TS2428: All declarations of 'WeakMap' must have identical type parameters.
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)

return true;
}
if (target.flags & TypeFlags.Intersection) {
return every((target as IntersectionType).types, t => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));

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.

Why do we need to have t === emptyTypeLiteralType here? Couldn't source not be assignable to {}?

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.

emptyTypeLiteralType isn't a valid type for a template literal placeholder. Without this, we run into problems with what this PR is fixing:

test failures
diff --git a/tests/baselines/reference/templateLiteralTypesPatterns.errors.txt b/tests/baselines/reference/templateLiteralTypesPatterns.errors.txt
index cd82afc839..7bd15a6f82 100644
--- a/tests/baselines/reference/templateLiteralTypesPatterns.errors.txt+++ b/tests/baselines/reference/templateLiteralTypesPatterns.errors.txt@@ -55,10 +55,12 @@ templateLiteralTypesPatterns.ts(129,9): error TS2345: Argument of type '"1.1e-10
templateLiteralTypesPatterns.ts(140,1): error TS2322: Type '`a${string}`' is not assignable to type '`a${number}`'.
templateLiteralTypesPatterns.ts(141,1): error TS2322: Type '"bno"' is not assignable to type '`a${any}`'.
templateLiteralTypesPatterns.ts(160,7): error TS2322: Type '"anything"' is not assignable to type '`${number} ${number}`'.
+templateLiteralTypesPatterns.ts(205,16): error TS2345: Argument of type '"testDowncast"' is not assignable to parameter of type '`${string & {}}Downcast` | "downcast" | "dataDowncast" | "editingDowncast"'.+templateLiteralTypesPatterns.ts(207,17): error TS2345: Argument of type '"testDowncast"' is not assignable to parameter of type '"downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`'.
templateLiteralTypesPatterns.ts(211,5): error TS2345: Argument of type '"abcTest"' is not assignable to parameter of type '`${`a${string}` & `${string}a`}Test`'.
-==== templateLiteralTypesPatterns.ts (58 errors) ====+==== templateLiteralTypesPatterns.ts (60 errors) ====
type RequiresLeadingSlash = `/${string}`;
// ok
@@ -378,8 +380,12 @@ templateLiteralTypesPatterns.ts(211,5): error TS2345: Argument of type '"abcTest
// repro from https://github.com/microsoft/TypeScript/issues/54177#issuecomment-1538436654
function conversionTest(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${string & {}}Downcast`) {}
conversionTest("testDowncast");
+ ~~~~~~~~~~~~~~+!!! error TS2345: Argument of type '"testDowncast"' is not assignable to parameter of type '`${string & {}}Downcast` | "downcast" | "dataDowncast" | "editingDowncast"'.
function conversionTest2(groupName: | "downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`) {}
conversionTest2("testDowncast");
+ ~~~~~~~~~~~~~~+!!! error TS2345: Argument of type '"testDowncast"' is not assignable to parameter of type '"downcast" | "dataDowncast" | "editingDowncast" | `${{} & string}Downcast`'.
function foo(str: `${`a${string}` & `${string}a`}Test`) {}
foo("abaTest"); // ok

This was really meant to be a "faster"/more concise version of:

if(target.flags&TypeFlags.Intersection){if(areIntersectedTypesAvoidingPrimitiveReduction((targetasIntersectionType).types)){constprimitive=(targetasIntersectionType).types[0]===emptyTypeLiteralType ? (targetasIntersectionType).types[1] : (targetasIntersectionType).types[0];returnisValidTypeForTemplateLiteralPlaceholder(source,primitive);}returnevery((targetasIntersectionType).types,t=>isValidTypeForTemplateLiteralPlaceholder(source,t));}

Couldn't source not be assignable to {}?

This is a good question. I've tried to end up with such a source and I couldn't figure out a way to hit this. The whole existing test suite also doesn't hit such a case. I won't swear that it's impossible though so maybe it's better to use this alternative version that I posted above?

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.

Ok, I looked at the code some more and I think this is actually ok (but like you said, I can't prove it's impossible).

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..54188
Metricmain54188DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used368,795k (± 0.01%)368,808k (± 0.01%)~368,778k368,859kp=0.575 n=6
Parse Time3.41s (± 0.82%)3.42s (± 1.16%)~3.37s3.47sp=0.871 n=6
Bind Time1.13s (± 0.72%)1.13s (± 0.46%)~1.12s1.13sp=0.929 n=6
Check Time8.95s (± 0.48%)8.98s (± 0.30%)~8.95s9.02sp=0.170 n=6
Emit Time7.55s (± 0.67%)7.56s (± 0.50%)~7.53s7.62sp=1.000 n=6
Total Time21.04s (± 0.32%)21.09s (± 0.34%)~20.99s21.16sp=0.199 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used192,105k (± 0.02%)193,080k (± 1.25%)~192,023k197,992kp=0.575 n=6
Parse Time1.53s (± 1.29%)1.52s (± 0.34%)~1.51s1.52sp=0.672 n=6
Bind Time0.78s (± 0.66%)0.78s (± 0.52%)~0.77s0.78sp=0.595 n=6
Check Time9.47s (± 0.48%)9.45s (± 0.56%)~9.40s9.51sp=0.570 n=6
Emit Time2.75s (± 1.07%)2.77s (± 0.67%)~2.75s2.80sp=0.064 n=6
Total Time14.52s (± 0.50%)14.52s (± 0.46%)~14.44s14.59sp=1.000 n=6
Monaco - node (v18.10.0, x64)
Memory used347,749k (± 0.01%)347,749k (± 0.01%)~347,729k347,776kp=0.873 n=6
Parse Time2.64s (± 0.57%)2.64s (± 0.82%)~2.62s2.67sp=0.743 n=6
Bind Time1.02s (± 1.01%)1.03s (± 0.87%)~1.02s1.04sp=0.054 n=6
Check Time7.29s (± 0.80%)7.33s (± 0.21%)~7.31s7.35sp=0.225 n=6
Emit Time4.26s (± 0.75%)4.29s (± 0.76%)~4.24s4.34sp=0.169 n=6
Total Time15.20s (± 0.53%)15.30s (± 0.39%)~15.20s15.36sp=0.054 n=6
TFS - node (v18.10.0, x64)
Memory used301,771k (± 0.01%)301,775k (± 0.01%)~301,751k301,804kp=0.810 n=6
Parse Time2.08s (± 0.93%)2.09s (± 0.25%)~2.09s2.10sp=0.212 n=6
Bind Time1.13s (± 0.67%)1.13s (± 0.00%)~1.13s1.13sp=0.598 n=6
Check Time6.67s (± 0.26%)6.70s (± 0.49%)~6.64s6.73sp=0.061 n=6
Emit Time3.85s (± 0.71%)3.91s (± 1.33%)~3.85s3.99sp=0.065 n=6
Total Time13.73s (± 0.26%)13.83s (± 0.50%)+0.10s (+ 0.72%)13.71s13.91sp=0.044 n=6
material-ui - node (v18.10.0, x64)
Memory used482,538k (± 0.01%)482,562k (± 0.00%)~482,540k482,585kp=0.128 n=6
Parse Time3.13s (± 0.48%)3.10s (± 2.18%)~2.97s3.16sp=0.405 n=6
Bind Time0.92s (± 0.82%)0.95s (± 4.47%)~0.92s1.03sp=0.150 n=6
Check Time17.34s (± 0.86%)17.36s (± 0.45%)~17.22s17.44sp=0.630 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time21.40s (± 0.67%)21.41s (± 0.42%)~21.24s21.49sp=0.688 n=6
xstate - node (v18.10.0, x64)
Memory used563,832k (± 0.03%)563,761k (± 0.02%)~563,661k563,947kp=0.423 n=6
Parse Time3.86s (± 0.59%)3.87s (± 0.35%)~3.85s3.88sp=0.101 n=6
Bind Time1.65s (± 0.50%)1.64s (± 0.46%)~1.63s1.65sp=0.554 n=6
Check Time2.82s (± 0.47%)2.83s (± 0.76%)~2.80s2.86sp=0.329 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time8.41s (± 0.50%)8.42s (± 0.22%)~8.41s8.46sp=0.332 n=6
Angular - node (v16.17.1, x64)
Memory used368,207k (± 0.00%)368,211k (± 0.00%)~368,192k368,230kp=0.748 n=6
Parse Time3.58s (± 0.23%)3.57s (± 0.59%)~3.55s3.60sp=0.461 n=6
Bind Time1.19s (± 0.43%)1.19s (± 0.34%)~1.18s1.19sp=0.114 n=6
Check Time9.73s (± 0.38%)9.78s (± 0.36%)~9.72s9.82sp=0.076 n=6
Emit Time8.03s (± 0.90%)8.07s (± 0.89%)~7.95s8.15sp=0.296 n=6
Total Time22.54s (± 0.39%)22.60s (± 0.41%)~22.49s22.74sp=0.470 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used193,810k (± 0.01%)193,835k (± 0.02%)~193,776k193,868kp=0.093 n=6
Parse Time1.59s (± 0.86%)1.60s (± 0.83%)~1.58s1.61sp=0.550 n=6
Bind Time0.83s (± 0.91%)0.82s (± 0.50%)~0.82s0.83sp=0.100 n=6
Check Time10.17s (± 0.67%)10.15s (± 0.53%)~10.06s10.22sp=0.747 n=6
Emit Time2.99s (± 0.40%)3.01s (± 0.62%)+0.02s (+ 0.67%)2.98s3.03sp=0.041 n=6
Total Time15.59s (± 0.42%)15.58s (± 0.44%)~15.51s15.69sp=0.574 n=6
Monaco - node (v16.17.1, x64)
Memory used347,060k (± 0.01%)347,093k (± 0.00%)~347,088k347,101kp=0.066 n=6
Parse Time2.77s (± 0.48%)2.77s (± 0.29%)~2.76s2.78sp=0.402 n=6
Bind Time1.08s (± 0.38%)1.08s (± 0.59%)~1.07s1.09sp=0.673 n=6
Check Time8.01s (± 0.41%)8.02s (± 0.57%)~7.97s8.09sp=0.687 n=6
Emit Time4.46s (± 1.09%)4.48s (± 0.65%)~4.45s4.53sp=0.334 n=6
Total Time16.32s (± 0.45%)16.36s (± 0.32%)~16.29s16.41sp=0.377 n=6
TFS - node (v16.17.1, x64)
Memory used301,112k (± 0.01%)301,112k (± 0.00%)~301,100k301,140kp=1.000 n=6
Parse Time2.21s (± 0.60%)2.22s (± 0.78%)~2.19s2.24sp=0.410 n=6
Bind Time1.21s (± 0.43%)1.21s (± 0.62%)~1.20s1.22sp=0.784 n=6
Check Time7.34s (± 0.43%)7.36s (± 0.25%)~7.33s7.38sp=0.331 n=6
Emit Time4.33s (± 0.56%)4.32s (± 0.55%)~4.29s4.35sp=0.808 n=6
Total Time15.09s (± 0.39%)15.10s (± 0.33%)~15.06s15.19sp=0.810 n=6
material-ui - node (v16.17.1, x64)
Memory used481,857k (± 0.01%)481,899k (± 0.00%)+43k (+ 0.01%)481,873k481,922kp=0.020 n=6
Parse Time3.25s (± 0.72%)3.27s (± 0.92%)~3.24s3.32sp=0.286 n=6
Bind Time0.96s (± 0.85%)0.96s (± 0.57%)~0.96s0.97sp=0.088 n=6
Check Time18.34s (± 0.79%)18.38s (± 0.31%)~18.33s18.48sp=0.377 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.55s (± 0.69%)22.61s (± 0.26%)~22.55s22.70sp=0.335 n=6
xstate - node (v16.17.1, x64)
Memory used561,332k (± 0.01%)561,388k (± 0.02%)~561,226k561,475kp=0.128 n=6
Parse Time4.02s (± 0.13%)4.02s (± 0.58%)~3.99s4.05sp=0.560 n=6
Bind Time1.77s (± 1.46%)1.71s (± 5.84%)~1.56s1.81sp=0.420 n=6
Check Time3.07s (± 0.57%)3.12s (± 2.56%)~3.07s3.27sp=0.164 n=6
Emit Time0.09s (± 5.53%)0.09s (± 0.00%)~0.09s0.09sp=0.174 n=6
Total Time8.94s (± 0.34%)8.94s (± 0.38%)~8.90s8.99sp=1.000 n=6
Angular - node (v14.21.3, x64)
Memory used362,106k (± 0.01%)362,144k (± 0.01%)~362,085k362,203kp=0.229 n=6
Parse Time3.74s (± 0.50%)3.73s (± 0.48%)~3.71s3.76sp=0.685 n=6
Bind Time1.22s (± 0.80%)1.22s (± 0.62%)~1.21s1.23sp=0.858 n=6
Check Time10.15s (± 0.46%)10.12s (± 0.37%)~10.06s10.17sp=0.229 n=6
Emit Time8.39s (± 0.53%)8.33s (± 0.40%)-0.06s (- 0.77%)8.28s8.38sp=0.024 n=6
Total Time23.50s (± 0.32%)23.40s (± 0.31%)~23.27s23.46sp=0.077 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used189,095k (± 0.02%)189,097k (± 0.01%)~189,072k189,115kp=0.936 n=6
Parse Time1.61s (± 0.32%)1.63s (± 0.51%)+0.01s (+ 0.72%)1.62s1.64sp=0.019 n=6
Bind Time0.85s (± 0.89%)0.85s (± 0.48%)~0.85s0.86sp=0.389 n=6
Check Time10.35s (± 0.35%)10.37s (± 0.55%)~10.28s10.44sp=0.747 n=6
Emit Time3.13s (± 1.23%)3.14s (± 0.68%)~3.12s3.17sp=0.293 n=6
Total Time15.94s (± 0.23%)15.98s (± 0.35%)~15.89s16.04sp=0.228 n=6
Monaco - node (v14.21.3, x64)
Memory used342,096k (± 0.01%)342,092k (± 0.00%)~342,068k342,105kp=0.936 n=6
Parse Time2.81s (± 0.29%)2.82s (± 0.29%)~2.81s2.83sp=0.077 n=6
Bind Time1.10s (± 0.74%)1.10s (± 0.37%)~1.10s1.11sp=0.584 n=6
Check Time8.33s (± 0.31%)8.30s (± 0.08%)~8.29s8.31sp=0.060 n=6
Emit Time4.67s (± 0.73%)4.67s (± 0.42%)~4.64s4.70sp=1.000 n=6
Total Time16.91s (± 0.22%)16.89s (± 0.11%)~16.86s16.91sp=0.361 n=6
TFS - node (v14.21.3, x64)
Memory used296,201k (± 0.00%)296,204k (± 0.01%)~296,184k296,226kp=1.000 n=6
Parse Time2.44s (± 0.79%)2.43s (± 1.02%)~2.40s2.46sp=0.460 n=6
Bind Time1.09s (± 0.75%)1.08s (± 0.83%)~1.07s1.09sp=0.270 n=6
Check Time7.67s (± 0.38%)7.69s (± 0.67%)~7.62s7.76sp=0.421 n=6
Emit Time4.29s (± 0.75%)4.30s (± 0.60%)~4.27s4.35sp=0.253 n=6
Total Time15.49s (± 0.28%)15.50s (± 0.55%)~15.40s15.65sp=0.936 n=6
material-ui - node (v14.21.3, x64)
Memory used477,357k (± 0.00%)477,342k (± 0.00%)~477,321k477,360kp=0.149 n=6
Parse Time3.32s (± 0.59%)3.31s (± 0.53%)~3.29s3.33sp=0.867 n=6
Bind Time0.99s (± 0.52%)1.00s (± 1.47%)~0.99s1.03sp=0.247 n=6
Check Time19.21s (± 0.89%)19.21s (± 0.67%)~19.11s19.43sp=0.810 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time23.51s (± 0.79%)23.53s (± 0.48%)~23.43s23.73sp=0.520 n=6
xstate - node (v14.21.3, x64)
Memory used550,175k (± 0.00%)550,175k (± 0.01%)~550,109k550,208kp=0.689 n=6
Parse Time4.21s (± 0.53%)4.23s (± 0.79%)~4.18s4.27sp=0.255 n=6
Bind Time1.69s (± 1.57%)1.69s (± 1.71%)~1.64s1.71sp=0.932 n=6
Check Time3.14s (± 0.62%)3.13s (± 0.63%)~3.11s3.16sp=0.571 n=6
Emit Time0.10s (± 4.15%)0.09s (± 5.76%)~0.09s0.10sp=0.282 n=6
Total Time9.14s (± 0.43%)9.15s (± 0.53%)~9.09s9.20sp=0.935 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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.21.3, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.21.3, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.21.3, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.21.3, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.21.3, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.21.3, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.21.3, x64)
BenchmarkNameIterations
Current541886
Baselinemain6

TSServer

Comparison Report - main..54188
Metricmain54188DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,552ms (± 0.66%)2,550ms (± 0.87%)~2,527ms2,590msp=0.810 n=6
Req 2 - geterr5,408ms (± 0.42%)5,412ms (± 0.33%)~5,391ms5,430msp=0.746 n=6
Req 3 - references342ms (± 0.95%)341ms (± 0.92%)~338ms346msp=0.573 n=6
Req 4 - navto289ms (± 0.63%)290ms (± 0.60%)~288ms293msp=0.683 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo76ms (± 0.68%)75ms (± 1.37%)~74ms77msp=0.437 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,633ms (± 0.70%)2,631ms (± 1.48%)~2,602ms2,685msp=0.378 n=6
Req 2 - geterr4,137ms (± 0.18%)4,137ms (± 0.39%)~4,112ms4,159msp=1.000 n=6
Req 3 - references351ms (± 0.42%)352ms (± 0.70%)~348ms354msp=0.461 n=6
Req 4 - navto289ms (± 0.26%)289ms (± 0.42%)~287ms290msp=0.315 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo79ms (± 1.04%)79ms (± 0.80%)~78ms80msp=0.432 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,099ms (± 0.51%)3,091ms (± 0.71%)~3,065ms3,127msp=0.378 n=6
Req 2 - geterr1,605ms (± 0.61%)1,594ms (± 1.07%)~1,570ms1,614msp=0.336 n=6
Req 3 - references117ms (± 6.57%)115ms (± 1.20%)~113ms116msp=0.935 n=6
Req 4 - navto372ms (± 1.16%)371ms (± 0.69%)~369ms375msp=0.809 n=6
Req 5 - completionInfo count2,872 (± 0.00%)2,872 (± 0.00%)~2,8722,872p=1.000 n=6
Req 5 - completionInfo383ms (± 1.28%)384ms (± 1.29%)~376ms390msp=0.747 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,637ms (± 0.75%)2,636ms (± 0.55%)~2,617ms2,651msp=0.810 n=6
Req 2 - geterr6,078ms (± 0.56%)6,053ms (± 0.65%)~5,986ms6,098msp=0.298 n=6
Req 3 - references357ms (± 1.29%)356ms (± 0.53%)~354ms359msp=0.681 n=6
Req 4 - navto286ms (± 0.85%)285ms (± 0.53%)~282ms286msp=0.683 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo83ms (± 7.57%)81ms (± 1.00%)~80ms82msp=0.448 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,819ms (± 0.60%)2,807ms (± 0.56%)~2,781ms2,823msp=0.378 n=6
Req 2 - geterr4,703ms (± 0.22%)4,687ms (± 0.34%)~4,666ms4,708msp=0.108 n=6
Req 3 - references363ms (± 0.71%)364ms (± 0.49%)~361ms366msp=0.506 n=6
Req 4 - navto283ms (± 1.24%)280ms (± 0.80%)~278ms284msp=0.223 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo78ms (± 5.12%)77ms (± 1.16%)~76ms78msp=0.801 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,236ms (± 0.65%)3,241ms (± 0.57%)~3,222ms3,268msp=0.689 n=6
Req 2 - geterr1,745ms (± 0.89%)1,750ms (± 0.50%)~1,739ms1,763msp=0.810 n=6
Req 3 - references126ms (± 6.56%)124ms (± 1.22%)~121ms125msp=0.568 n=6
Req 4 - navto352ms (± 0.59%)353ms (± 0.49%)~351ms356msp=0.807 n=6
Req 5 - completionInfo count2,872 (± 0.00%)2,872 (± 0.00%)~2,8722,872p=1.000 n=6
Req 5 - completionInfo424ms (± 1.07%)421ms (± 0.81%)~417ms426msp=0.196 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,758ms (± 0.49%)2,778ms (± 0.25%)+20ms (+ 0.73%)2,765ms2,785msp=0.016 n=6
Req 2 - geterr6,191ms (± 0.67%)6,247ms (± 0.95%)+56ms (+ 0.91%)6,192ms6,355msp=0.045 n=6
Req 3 - references361ms (± 0.78%)364ms (± 1.00%)~361ms371msp=0.142 n=6
Req 4 - navto293ms (± 0.73%)291ms (± 0.35%)~290ms293msp=0.251 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo99ms (± 8.70%)106ms (± 6.22%)~97ms111msp=0.081 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,927ms (± 0.25%)2,950ms (± 0.54%)+23ms (+ 0.77%)2,936ms2,978msp=0.008 n=6
Req 2 - geterr4,613ms (± 1.42%)4,594ms (± 0.38%)~4,564ms4,616msp=0.689 n=6
Req 3 - references371ms (± 0.47%)369ms (± 0.33%)~368ms371msp=0.303 n=6
Req 4 - navto298ms (± 1.06%)299ms (± 0.25%)~298ms300msp=0.934 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo84ms (± 1.17%)83ms (± 0.98%)~82ms84msp=0.282 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen3,516ms (± 0.66%)3,501ms (± 1.43%)~3,436ms3,550msp=0.810 n=6
Req 2 - geterr1,880ms (± 0.76%)1,855ms (± 0.49%)-25ms (- 1.30%)1,839ms1,862msp=0.031 n=6
Req 3 - references146ms (± 8.16%)143ms (± 9.10%)~130ms156msp=0.872 n=6
Req 4 - navto388ms (± 0.53%)391ms (± 1.01%)~387ms396msp=0.334 n=6
Req 5 - completionInfo count2,872 (± 0.00%)2,872 (± 0.00%)~2,8722,872p=1.000 n=6
Req 5 - completionInfo422ms (± 1.21%)424ms (± 1.05%)~418ms430msp=0.748 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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.21.3, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.21.3, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.21.3, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.21.3, x64)
BenchmarkNameIterations
Current541886
Baselinemain6

Startup

Comparison Report - main..54188
Metricmain54188DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time144.61ms (± 0.56%)142.99ms (± 0.18%)-1.62ms (- 1.12%)142.31ms145.89msp=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time223.75ms (± 0.39%)222.76ms (± 0.15%)-0.99ms (- 0.44%)221.81ms226.86msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time226.21ms (± 0.37%)224.02ms (± 0.19%)-2.18ms (- 0.96%)223.10ms231.61msp=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time208.02ms (± 0.37%)206.08ms (± 0.18%)-1.94ms (- 0.93%)205.17ms209.99msp=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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
Current541886
Baselinemain6

Developer Information:

Download Benchmark

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top-repos suite comparing main and refs/pull/54188/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top-repos suite comparing main and refs/pull/54188/merge:

Something interesting changed - please have a look.

Details

Server exited prematurely with code unknown and signal SIGABRT

Server exited prematurely with code unknown and signal SIGABRT

Affected repos

calcom/cal.com Raw error text: RepoResults4/calcom.cal.com.rawError.txt in the artifact folder

Last few requests

{"seq":864,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/apps/swagger/pages/_app.tsx","projectRootPath":"@PROJECT_ROOT@"}]}}
{"seq":865,"type":"request","command":"getOutliningSpans","arguments":{"file":"@PROJECT_ROOT@/apps/swagger/pages/_app.tsx"}}
{"seq":866,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":["@PROJECT_ROOT@/apps/storybook/components/Title.tsx"],"openFiles":[]}}
{"seq":867,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/apps/web/components/apps/App.tsx","projectRootPath":"@PROJECT_ROOT@"}]}}

Repro steps

  1. git clone https://github.com/calcom/cal.com --recurse-submodules
  2. In dir cal.com, run git reset --hard 1b6d1b3a5a84dc86b8b89d08c4e052221735e201
  3. In dir cal.com, run yarn install --no-immutable --mode=skip-build
  4. Back in the initial folder, download RepoResults4/calcom.cal.com.replay.txt from the artifact folder
  5. npm install --no-save @typescript/server-replay
  6. npx tsreplay ./cal.com ./calcom.cal.com.replay.txt path/to/tsserver.js
  7. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Gabriela Araujo Britto (@gabritto), the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@gabritto

Copy link
Copy Markdown
Member

It looks like this PR caused an out of memory error on a repo: #54188 (comment)

@Andarist

Mateusz Burzyński (Andarist) commented Aug 4, 2023

Copy link
Copy Markdown
ContributorAuthor

Gabriela Araujo Britto (@gabritto) I'm not sure if this failure is related to this PR. I can repro it but I can repro it using the build from main as well.

@gabritto

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test tsserver top100

@typescript-bot

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

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based top-repos suite (tsserver) on this PR at f5f1403. You can monitor the build here.

Update: The results are in!

@Andarist

Copy link
Copy Markdown
ContributorAuthor

Gabriela Araujo Britto (@gabritto) I'm not sure if this failure is related to this PR. I can repro it but I can repro it using the build from main as well.

I might have misinterpreted the results in the rush. I can't repro this with either build (from this PR and from the main). Now I'm interested if the CI job will be able to repro it again 😅

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top-repos suite comparing main and refs/pull/54188/merge:

Everything looks good!

@gabritto

Copy link
Copy Markdown
Member

Seems like CI is fine now? I think this looks good for 5.3.

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.

Template Literal Types reduces string union

5 participants

@Andarist@gabritto@typescript-bot@sandersn@ahejlsberg