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

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

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 8, 2023

@gabritto
Copy link
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.

@sandersn 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
Contributor Author

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:

function conversionTest(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:

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

@Andarist Andarist force-pushed the fix/intersections-as-valid-types-for-template-literal-placeholders branch from 0a12f3e to f5f1403 Compare July 28, 2023 22:33
@gabritto

This comment was marked as duplicate.

@gabritto
Copy link
Member

gabritto commented Aug 2, 2023

@typescript-bot test this
@typescript-bot run DT
@typescript-bot user test this
@typescript-bot user test tsserver
@typescript-bot test top100
@typescript-bot test tsserver top100
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 2, 2023

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

typescript-bot commented Aug 2, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 2, 2023

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

typescript-bot commented Aug 2, 2023

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

typescript-bot commented Aug 2, 2023

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

typescript-bot commented Aug 2, 2023

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

typescript-bot commented Aug 2, 2023

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

gabritto commented Aug 2, 2023

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 2, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 2, 2023

Hey @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/[email protected]".;

@typescript-bot
Copy link
Collaborator

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

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

@@ -24312,12 +24320,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (source === target || target.flags & (TypeFlags.Any | TypeFlags.String)) {
return true;
}
if (target.flags & TypeFlags.Intersection) {
return every((target as IntersectionType).types, t => t === emptyTypeLiteralType || isValidTypeForTemplateLiteralPlaceholder(source, t));
Copy link
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
Contributor Author

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((target as IntersectionType).types)) {
                const primitive = (target as IntersectionType).types[0] === emptyTypeLiteralType ? (target as IntersectionType).types[1] : (target as IntersectionType).types[0];
                return isValidTypeForTemplateLiteralPlaceholder(source, primitive);
            }
            return every((target as IntersectionType).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
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
Collaborator

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

Here they are:

Compiler

Comparison Report - main..54188
Metric main 54188 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 368,795k (± 0.01%) 368,808k (± 0.01%) ~ 368,778k 368,859k p=0.575 n=6
Parse Time 3.41s (± 0.82%) 3.42s (± 1.16%) ~ 3.37s 3.47s p=0.871 n=6
Bind Time 1.13s (± 0.72%) 1.13s (± 0.46%) ~ 1.12s 1.13s p=0.929 n=6
Check Time 8.95s (± 0.48%) 8.98s (± 0.30%) ~ 8.95s 9.02s p=0.170 n=6
Emit Time 7.55s (± 0.67%) 7.56s (± 0.50%) ~ 7.53s 7.62s p=1.000 n=6
Total Time 21.04s (± 0.32%) 21.09s (± 0.34%) ~ 20.99s 21.16s p=0.199 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 192,105k (± 0.02%) 193,080k (± 1.25%) ~ 192,023k 197,992k p=0.575 n=6
Parse Time 1.53s (± 1.29%) 1.52s (± 0.34%) ~ 1.51s 1.52s p=0.672 n=6
Bind Time 0.78s (± 0.66%) 0.78s (± 0.52%) ~ 0.77s 0.78s p=0.595 n=6
Check Time 9.47s (± 0.48%) 9.45s (± 0.56%) ~ 9.40s 9.51s p=0.570 n=6
Emit Time 2.75s (± 1.07%) 2.77s (± 0.67%) ~ 2.75s 2.80s p=0.064 n=6
Total Time 14.52s (± 0.50%) 14.52s (± 0.46%) ~ 14.44s 14.59s p=1.000 n=6
Monaco - node (v18.10.0, x64)
Memory used 347,749k (± 0.01%) 347,749k (± 0.01%) ~ 347,729k 347,776k p=0.873 n=6
Parse Time 2.64s (± 0.57%) 2.64s (± 0.82%) ~ 2.62s 2.67s p=0.743 n=6
Bind Time 1.02s (± 1.01%) 1.03s (± 0.87%) ~ 1.02s 1.04s p=0.054 n=6
Check Time 7.29s (± 0.80%) 7.33s (± 0.21%) ~ 7.31s 7.35s p=0.225 n=6
Emit Time 4.26s (± 0.75%) 4.29s (± 0.76%) ~ 4.24s 4.34s p=0.169 n=6
Total Time 15.20s (± 0.53%) 15.30s (± 0.39%) ~ 15.20s 15.36s p=0.054 n=6
TFS - node (v18.10.0, x64)
Memory used 301,771k (± 0.01%) 301,775k (± 0.01%) ~ 301,751k 301,804k p=0.810 n=6
Parse Time 2.08s (± 0.93%) 2.09s (± 0.25%) ~ 2.09s 2.10s p=0.212 n=6
Bind Time 1.13s (± 0.67%) 1.13s (± 0.00%) ~ 1.13s 1.13s p=0.598 n=6
Check Time 6.67s (± 0.26%) 6.70s (± 0.49%) ~ 6.64s 6.73s p=0.061 n=6
Emit Time 3.85s (± 0.71%) 3.91s (± 1.33%) ~ 3.85s 3.99s p=0.065 n=6
Total Time 13.73s (± 0.26%) 13.83s (± 0.50%) +0.10s (+ 0.72%) 13.71s 13.91s p=0.044 n=6
material-ui - node (v18.10.0, x64)
Memory used 482,538k (± 0.01%) 482,562k (± 0.00%) ~ 482,540k 482,585k p=0.128 n=6
Parse Time 3.13s (± 0.48%) 3.10s (± 2.18%) ~ 2.97s 3.16s p=0.405 n=6
Bind Time 0.92s (± 0.82%) 0.95s (± 4.47%) ~ 0.92s 1.03s p=0.150 n=6
Check Time 17.34s (± 0.86%) 17.36s (± 0.45%) ~ 17.22s 17.44s p=0.630 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 21.40s (± 0.67%) 21.41s (± 0.42%) ~ 21.24s 21.49s p=0.688 n=6
xstate - node (v18.10.0, x64)
Memory used 563,832k (± 0.03%) 563,761k (± 0.02%) ~ 563,661k 563,947k p=0.423 n=6
Parse Time 3.86s (± 0.59%) 3.87s (± 0.35%) ~ 3.85s 3.88s p=0.101 n=6
Bind Time 1.65s (± 0.50%) 1.64s (± 0.46%) ~ 1.63s 1.65s p=0.554 n=6
Check Time 2.82s (± 0.47%) 2.83s (± 0.76%) ~ 2.80s 2.86s p=0.329 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.41s (± 0.50%) 8.42s (± 0.22%) ~ 8.41s 8.46s p=0.332 n=6
Angular - node (v16.17.1, x64)
Memory used 368,207k (± 0.00%) 368,211k (± 0.00%) ~ 368,192k 368,230k p=0.748 n=6
Parse Time 3.58s (± 0.23%) 3.57s (± 0.59%) ~ 3.55s 3.60s p=0.461 n=6
Bind Time 1.19s (± 0.43%) 1.19s (± 0.34%) ~ 1.18s 1.19s p=0.114 n=6
Check Time 9.73s (± 0.38%) 9.78s (± 0.36%) ~ 9.72s 9.82s p=0.076 n=6
Emit Time 8.03s (± 0.90%) 8.07s (± 0.89%) ~ 7.95s 8.15s p=0.296 n=6
Total Time 22.54s (± 0.39%) 22.60s (± 0.41%) ~ 22.49s 22.74s p=0.470 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,810k (± 0.01%) 193,835k (± 0.02%) ~ 193,776k 193,868k p=0.093 n=6
Parse Time 1.59s (± 0.86%) 1.60s (± 0.83%) ~ 1.58s 1.61s p=0.550 n=6
Bind Time 0.83s (± 0.91%) 0.82s (± 0.50%) ~ 0.82s 0.83s p=0.100 n=6
Check Time 10.17s (± 0.67%) 10.15s (± 0.53%) ~ 10.06s 10.22s p=0.747 n=6
Emit Time 2.99s (± 0.40%) 3.01s (± 0.62%) +0.02s (+ 0.67%) 2.98s 3.03s p=0.041 n=6
Total Time 15.59s (± 0.42%) 15.58s (± 0.44%) ~ 15.51s 15.69s p=0.574 n=6
Monaco - node (v16.17.1, x64)
Memory used 347,060k (± 0.01%) 347,093k (± 0.00%) ~ 347,088k 347,101k p=0.066 n=6
Parse Time 2.77s (± 0.48%) 2.77s (± 0.29%) ~ 2.76s 2.78s p=0.402 n=6
Bind Time 1.08s (± 0.38%) 1.08s (± 0.59%) ~ 1.07s 1.09s p=0.673 n=6
Check Time 8.01s (± 0.41%) 8.02s (± 0.57%) ~ 7.97s 8.09s p=0.687 n=6
Emit Time 4.46s (± 1.09%) 4.48s (± 0.65%) ~ 4.45s 4.53s p=0.334 n=6
Total Time 16.32s (± 0.45%) 16.36s (± 0.32%) ~ 16.29s 16.41s p=0.377 n=6
TFS - node (v16.17.1, x64)
Memory used 301,112k (± 0.01%) 301,112k (± 0.00%) ~ 301,100k 301,140k p=1.000 n=6
Parse Time 2.21s (± 0.60%) 2.22s (± 0.78%) ~ 2.19s 2.24s p=0.410 n=6
Bind Time 1.21s (± 0.43%) 1.21s (± 0.62%) ~ 1.20s 1.22s p=0.784 n=6
Check Time 7.34s (± 0.43%) 7.36s (± 0.25%) ~ 7.33s 7.38s p=0.331 n=6
Emit Time 4.33s (± 0.56%) 4.32s (± 0.55%) ~ 4.29s 4.35s p=0.808 n=6
Total Time 15.09s (± 0.39%) 15.10s (± 0.33%) ~ 15.06s 15.19s p=0.810 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,857k (± 0.01%) 481,899k (± 0.00%) +43k (+ 0.01%) 481,873k 481,922k p=0.020 n=6
Parse Time 3.25s (± 0.72%) 3.27s (± 0.92%) ~ 3.24s 3.32s p=0.286 n=6
Bind Time 0.96s (± 0.85%) 0.96s (± 0.57%) ~ 0.96s 0.97s p=0.088 n=6
Check Time 18.34s (± 0.79%) 18.38s (± 0.31%) ~ 18.33s 18.48s p=0.377 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.55s (± 0.69%) 22.61s (± 0.26%) ~ 22.55s 22.70s p=0.335 n=6
xstate - node (v16.17.1, x64)
Memory used 561,332k (± 0.01%) 561,388k (± 0.02%) ~ 561,226k 561,475k p=0.128 n=6
Parse Time 4.02s (± 0.13%) 4.02s (± 0.58%) ~ 3.99s 4.05s p=0.560 n=6
Bind Time 1.77s (± 1.46%) 1.71s (± 5.84%) ~ 1.56s 1.81s p=0.420 n=6
Check Time 3.07s (± 0.57%) 3.12s (± 2.56%) ~ 3.07s 3.27s p=0.164 n=6
Emit Time 0.09s (± 5.53%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=0.174 n=6
Total Time 8.94s (± 0.34%) 8.94s (± 0.38%) ~ 8.90s 8.99s p=1.000 n=6
Angular - node (v14.21.3, x64)
Memory used 362,106k (± 0.01%) 362,144k (± 0.01%) ~ 362,085k 362,203k p=0.229 n=6
Parse Time 3.74s (± 0.50%) 3.73s (± 0.48%) ~ 3.71s 3.76s p=0.685 n=6
Bind Time 1.22s (± 0.80%) 1.22s (± 0.62%) ~ 1.21s 1.23s p=0.858 n=6
Check Time 10.15s (± 0.46%) 10.12s (± 0.37%) ~ 10.06s 10.17s p=0.229 n=6
Emit Time 8.39s (± 0.53%) 8.33s (± 0.40%) -0.06s (- 0.77%) 8.28s 8.38s p=0.024 n=6
Total Time 23.50s (± 0.32%) 23.40s (± 0.31%) ~ 23.27s 23.46s p=0.077 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used 189,095k (± 0.02%) 189,097k (± 0.01%) ~ 189,072k 189,115k p=0.936 n=6
Parse Time 1.61s (± 0.32%) 1.63s (± 0.51%) +0.01s (+ 0.72%) 1.62s 1.64s p=0.019 n=6
Bind Time 0.85s (± 0.89%) 0.85s (± 0.48%) ~ 0.85s 0.86s p=0.389 n=6
Check Time 10.35s (± 0.35%) 10.37s (± 0.55%) ~ 10.28s 10.44s p=0.747 n=6
Emit Time 3.13s (± 1.23%) 3.14s (± 0.68%) ~ 3.12s 3.17s p=0.293 n=6
Total Time 15.94s (± 0.23%) 15.98s (± 0.35%) ~ 15.89s 16.04s p=0.228 n=6
Monaco - node (v14.21.3, x64)
Memory used 342,096k (± 0.01%) 342,092k (± 0.00%) ~ 342,068k 342,105k p=0.936 n=6
Parse Time 2.81s (± 0.29%) 2.82s (± 0.29%) ~ 2.81s 2.83s p=0.077 n=6
Bind Time 1.10s (± 0.74%) 1.10s (± 0.37%) ~ 1.10s 1.11s p=0.584 n=6
Check Time 8.33s (± 0.31%) 8.30s (± 0.08%) ~ 8.29s 8.31s p=0.060 n=6
Emit Time 4.67s (± 0.73%) 4.67s (± 0.42%) ~ 4.64s 4.70s p=1.000 n=6
Total Time 16.91s (± 0.22%) 16.89s (± 0.11%) ~ 16.86s 16.91s p=0.361 n=6
TFS - node (v14.21.3, x64)
Memory used 296,201k (± 0.00%) 296,204k (± 0.01%) ~ 296,184k 296,226k p=1.000 n=6
Parse Time 2.44s (± 0.79%) 2.43s (± 1.02%) ~ 2.40s 2.46s p=0.460 n=6
Bind Time 1.09s (± 0.75%) 1.08s (± 0.83%) ~ 1.07s 1.09s p=0.270 n=6
Check Time 7.67s (± 0.38%) 7.69s (± 0.67%) ~ 7.62s 7.76s p=0.421 n=6
Emit Time 4.29s (± 0.75%) 4.30s (± 0.60%) ~ 4.27s 4.35s p=0.253 n=6
Total Time 15.49s (± 0.28%) 15.50s (± 0.55%) ~ 15.40s 15.65s p=0.936 n=6
material-ui - node (v14.21.3, x64)
Memory used 477,357k (± 0.00%) 477,342k (± 0.00%) ~ 477,321k 477,360k p=0.149 n=6
Parse Time 3.32s (± 0.59%) 3.31s (± 0.53%) ~ 3.29s 3.33s p=0.867 n=6
Bind Time 0.99s (± 0.52%) 1.00s (± 1.47%) ~ 0.99s 1.03s p=0.247 n=6
Check Time 19.21s (± 0.89%) 19.21s (± 0.67%) ~ 19.11s 19.43s 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 23.51s (± 0.79%) 23.53s (± 0.48%) ~ 23.43s 23.73s p=0.520 n=6
xstate - node (v14.21.3, x64)
Memory used 550,175k (± 0.00%) 550,175k (± 0.01%) ~ 550,109k 550,208k p=0.689 n=6
Parse Time 4.21s (± 0.53%) 4.23s (± 0.79%) ~ 4.18s 4.27s p=0.255 n=6
Bind Time 1.69s (± 1.57%) 1.69s (± 1.71%) ~ 1.64s 1.71s p=0.932 n=6
Check Time 3.14s (± 0.62%) 3.13s (± 0.63%) ~ 3.11s 3.16s p=0.571 n=6
Emit Time 0.10s (± 4.15%) 0.09s (± 5.76%) ~ 0.09s 0.10s p=0.282 n=6
Total Time 9.14s (± 0.43%) 9.15s (± 0.53%) ~ 9.09s 9.20s p=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)
Benchmark Name Iterations
Current 54188 6
Baseline main 6

TSServer

Comparison Report - main..54188
Metric main 54188 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,552ms (± 0.66%) 2,550ms (± 0.87%) ~ 2,527ms 2,590ms p=0.810 n=6
Req 2 - geterr 5,408ms (± 0.42%) 5,412ms (± 0.33%) ~ 5,391ms 5,430ms p=0.746 n=6
Req 3 - references 342ms (± 0.95%) 341ms (± 0.92%) ~ 338ms 346ms p=0.573 n=6
Req 4 - navto 289ms (± 0.63%) 290ms (± 0.60%) ~ 288ms 293ms p=0.683 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 76ms (± 0.68%) 75ms (± 1.37%) ~ 74ms 77ms p=0.437 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,633ms (± 0.70%) 2,631ms (± 1.48%) ~ 2,602ms 2,685ms p=0.378 n=6
Req 2 - geterr 4,137ms (± 0.18%) 4,137ms (± 0.39%) ~ 4,112ms 4,159ms p=1.000 n=6
Req 3 - references 351ms (± 0.42%) 352ms (± 0.70%) ~ 348ms 354ms p=0.461 n=6
Req 4 - navto 289ms (± 0.26%) 289ms (± 0.42%) ~ 287ms 290ms p=0.315 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 79ms (± 1.04%) 79ms (± 0.80%) ~ 78ms 80ms p=0.432 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,099ms (± 0.51%) 3,091ms (± 0.71%) ~ 3,065ms 3,127ms p=0.378 n=6
Req 2 - geterr 1,605ms (± 0.61%) 1,594ms (± 1.07%) ~ 1,570ms 1,614ms p=0.336 n=6
Req 3 - references 117ms (± 6.57%) 115ms (± 1.20%) ~ 113ms 116ms p=0.935 n=6
Req 4 - navto 372ms (± 1.16%) 371ms (± 0.69%) ~ 369ms 375ms p=0.809 n=6
Req 5 - completionInfo count 2,872 (± 0.00%) 2,872 (± 0.00%) ~ 2,872 2,872 p=1.000 n=6
Req 5 - completionInfo 383ms (± 1.28%) 384ms (± 1.29%) ~ 376ms 390ms p=0.747 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,637ms (± 0.75%) 2,636ms (± 0.55%) ~ 2,617ms 2,651ms p=0.810 n=6
Req 2 - geterr 6,078ms (± 0.56%) 6,053ms (± 0.65%) ~ 5,986ms 6,098ms p=0.298 n=6
Req 3 - references 357ms (± 1.29%) 356ms (± 0.53%) ~ 354ms 359ms p=0.681 n=6
Req 4 - navto 286ms (± 0.85%) 285ms (± 0.53%) ~ 282ms 286ms p=0.683 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 83ms (± 7.57%) 81ms (± 1.00%) ~ 80ms 82ms p=0.448 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,819ms (± 0.60%) 2,807ms (± 0.56%) ~ 2,781ms 2,823ms p=0.378 n=6
Req 2 - geterr 4,703ms (± 0.22%) 4,687ms (± 0.34%) ~ 4,666ms 4,708ms p=0.108 n=6
Req 3 - references 363ms (± 0.71%) 364ms (± 0.49%) ~ 361ms 366ms p=0.506 n=6
Req 4 - navto 283ms (± 1.24%) 280ms (± 0.80%) ~ 278ms 284ms p=0.223 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 78ms (± 5.12%) 77ms (± 1.16%) ~ 76ms 78ms p=0.801 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,236ms (± 0.65%) 3,241ms (± 0.57%) ~ 3,222ms 3,268ms p=0.689 n=6
Req 2 - geterr 1,745ms (± 0.89%) 1,750ms (± 0.50%) ~ 1,739ms 1,763ms p=0.810 n=6
Req 3 - references 126ms (± 6.56%) 124ms (± 1.22%) ~ 121ms 125ms p=0.568 n=6
Req 4 - navto 352ms (± 0.59%) 353ms (± 0.49%) ~ 351ms 356ms p=0.807 n=6
Req 5 - completionInfo count 2,872 (± 0.00%) 2,872 (± 0.00%) ~ 2,872 2,872 p=1.000 n=6
Req 5 - completionInfo 424ms (± 1.07%) 421ms (± 0.81%) ~ 417ms 426ms p=0.196 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,758ms (± 0.49%) 2,778ms (± 0.25%) +20ms (+ 0.73%) 2,765ms 2,785ms p=0.016 n=6
Req 2 - geterr 6,191ms (± 0.67%) 6,247ms (± 0.95%) +56ms (+ 0.91%) 6,192ms 6,355ms p=0.045 n=6
Req 3 - references 361ms (± 0.78%) 364ms (± 1.00%) ~ 361ms 371ms p=0.142 n=6
Req 4 - navto 293ms (± 0.73%) 291ms (± 0.35%) ~ 290ms 293ms p=0.251 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 99ms (± 8.70%) 106ms (± 6.22%) ~ 97ms 111ms p=0.081 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,927ms (± 0.25%) 2,950ms (± 0.54%) +23ms (+ 0.77%) 2,936ms 2,978ms p=0.008 n=6
Req 2 - geterr 4,613ms (± 1.42%) 4,594ms (± 0.38%) ~ 4,564ms 4,616ms p=0.689 n=6
Req 3 - references 371ms (± 0.47%) 369ms (± 0.33%) ~ 368ms 371ms p=0.303 n=6
Req 4 - navto 298ms (± 1.06%) 299ms (± 0.25%) ~ 298ms 300ms p=0.934 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 84ms (± 1.17%) 83ms (± 0.98%) ~ 82ms 84ms p=0.282 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 3,516ms (± 0.66%) 3,501ms (± 1.43%) ~ 3,436ms 3,550ms p=0.810 n=6
Req 2 - geterr 1,880ms (± 0.76%) 1,855ms (± 0.49%) -25ms (- 1.30%) 1,839ms 1,862ms p=0.031 n=6
Req 3 - references 146ms (± 8.16%) 143ms (± 9.10%) ~ 130ms 156ms p=0.872 n=6
Req 4 - navto 388ms (± 0.53%) 391ms (± 1.01%) ~ 387ms 396ms p=0.334 n=6
Req 5 - completionInfo count 2,872 (± 0.00%) 2,872 (± 0.00%) ~ 2,872 2,872 p=1.000 n=6
Req 5 - completionInfo 422ms (± 1.21%) 424ms (± 1.05%) ~ 418ms 430ms p=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)
Benchmark Name Iterations
Current 54188 6
Baseline main 6

Startup

Comparison Report - main..54188
Metric main 54188 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 144.61ms (± 0.56%) 142.99ms (± 0.18%) -1.62ms (- 1.12%) 142.31ms 145.89ms p=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 223.75ms (± 0.39%) 222.76ms (± 0.15%) -0.99ms (- 0.44%) 221.81ms 226.86ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 226.21ms (± 0.37%) 224.02ms (± 0.19%) -2.18ms (- 0.96%) 223.10ms 231.61ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 208.02ms (± 0.37%) 206.08ms (± 0.18%) -1.94ms (- 0.93%) 205.17ms 209.99ms p=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)
Benchmark Name Iterations
Current 54188 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

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

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

@gabritto
Copy link
Member

gabritto commented Aug 2, 2023

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

@Andarist
Copy link
Contributor Author

Andarist commented Aug 4, 2023

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

gabritto commented Aug 4, 2023

@typescript-bot test tsserver top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 4, 2023

Heya @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
Contributor Author

Andarist commented Aug 4, 2023

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

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

Everything looks good!

@gabritto
Copy link
Member

gabritto commented Aug 4, 2023

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

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.

Template Literal Types reduces string union
5 participants