Skip to content

Improve apparent type of mapped types - #57122

Merged
Anders Hejlsberg (ahejlsberg) merged 9 commits into
mainfrom
fix56726
Feb 19, 2024
Merged

Improve apparent type of mapped types#57122
Anders Hejlsberg (ahejlsberg) merged 9 commits into
mainfrom
fix56726

Conversation

@ahejlsberg

@ahejlsbergAnders Hejlsberg (ahejlsberg) commented Jan 22, 2024

Copy link
Copy Markdown
Member

This PR supersedes #56727 (which was reverted). The improvements in this PR don't exhibit the issue that caused us to revert #56727.

EDIT: However, the PR does break one test because the improved resolution of apparent types for mapped types causes the issue reported in #29919 to surface in that test.

I'm going to recommend we merge #50034, which fixes#29919 and thus the broken test in this PR.

Fixes#29919.
Fixes#56726.

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 14724a0. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 14724a0. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based top-repos suite on this PR at 14724a0. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the faster perf test suite on this PR at 14724a0. You can monitor the build here.

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user test suite comparing main and refs/pull/57122/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,658k (± 0.01%)295,647k (± 0.01%)~295,616k295,664kp=0.688 n=6
Parse Time2.67s (± 0.33%)2.66s (± 0.34%)~2.65s2.67sp=0.113 n=6
Bind Time0.83s (± 0.49%)0.83s (± 1.32%)~0.82s0.85sp=1.000 n=6
Check Time8.20s (± 0.21%)8.19s (± 0.46%)~8.14s8.25sp=0.366 n=6
Emit Time7.09s (± 0.16%)7.10s (± 0.25%)~7.08s7.13sp=0.212 n=6
Total Time18.78s (± 0.11%)18.78s (± 0.23%)~18.72s18.84sp=0.872 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used193,470k (± 1.54%)192,513k (± 1.23%)~191,509k197,342kp=0.810 n=6
Parse Time1.37s (± 1.22%)1.36s (± 1.18%)~1.34s1.38sp=0.438 n=6
Bind Time0.72s (± 0.00%)0.72s (± 0.00%)~0.72s0.72sp=1.000 n=6
Check Time9.36s (± 0.55%)9.39s (± 0.37%)~9.33s9.42sp=0.464 n=6
Emit Time2.62s (± 0.56%)2.61s (± 0.70%)~2.60s2.64sp=0.601 n=6
Total Time14.07s (± 0.31%)14.08s (± 0.24%)~14.03s14.13sp=0.627 n=6
Monaco - node (v18.15.0, x64)
Memory used347,451k (± 0.00%)347,446k (± 0.00%)~347,421k347,463kp=0.630 n=6
Parse Time2.48s (± 0.34%)2.48s (± 0.74%)~2.46s2.50sp=0.566 n=6
Bind Time0.93s (± 0.00%)0.93s (± 0.56%)~0.92s0.93sp=0.174 n=6
Check Time6.92s (± 0.31%)6.94s (± 0.35%)~6.92s6.98sp=0.415 n=6
Emit Time4.07s (± 0.88%)4.05s (± 0.19%)~4.04s4.06sp=0.864 n=6
Total Time14.40s (± 0.35%)14.40s (± 0.28%)~14.35s14.46sp=0.872 n=6
TFS - node (v18.15.0, x64)
Memory used302,836k (± 0.00%)302,839k (± 0.01%)~302,812k302,898kp=0.936 n=6
Parse Time2.03s (± 0.51%)2.01s (± 0.96%)~1.99s2.04sp=0.190 n=6
Bind Time1.00s (± 0.52%)1.01s (± 0.88%)+0.01s (+ 1.34%)1.00s1.02sp=0.020 n=6
Check Time6.34s (± 0.37%)6.34s (± 0.40%)~6.31s6.37sp=0.746 n=6
Emit Time3.61s (± 0.65%)3.60s (± 0.80%)~3.56s3.64sp=1.000 n=6
Total Time12.96s (± 0.24%)12.97s (± 0.36%)~12.91s13.02sp=0.871 n=6
material-ui - node (v18.15.0, x64)
Memory used511,284k (± 0.00%)511,301k (± 0.01%)~511,259k511,338kp=0.470 n=6
Parse Time2.65s (± 0.60%)2.65s (± 0.62%)~2.63s2.67sp=0.934 n=6
Bind Time0.99s (± 0.76%)1.00s (± 1.17%)~0.99s1.02sp=0.383 n=6
Check Time17.21s (± 0.32%)17.21s (± 0.28%)~17.12s17.26sp=0.810 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.85s (± 0.27%)20.86s (± 0.31%)~20.73s20.90sp=0.517 n=6
mui-docs - node (v18.15.0, x64)
Memory used1,696,014k (± 0.00%)1,695,540k (± 0.00%)-474k (- 0.03%)1,695,501k1,695,579kp=0.005 n=6
Parse Time6.53s (± 0.26%)6.55s (± 0.50%)~6.51s6.60sp=0.252 n=6
Bind Time2.35s (± 0.50%)2.35s (± 0.32%)~2.34s2.36sp=0.734 n=6
Check Time55.36s (± 0.30%)55.33s (± 0.35%)~55.01s55.57sp=0.936 n=6
Emit Time0.16s (± 0.00%)0.16s (± 0.00%)~0.16s0.16sp=1.000 n=6
Total Time64.39s (± 0.27%)64.39s (± 0.31%)~64.06s64.61sp=0.810 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,412,920k (± 0.04%)2,412,952k (± 0.04%)~2,412,045k2,414,651kp=0.936 n=6
Parse Time4.94s (± 0.88%)4.95s (± 1.00%)~4.90s5.01sp=0.471 n=6
Bind Time1.87s (± 0.89%)1.87s (± 1.64%)~1.83s1.91sp=1.000 n=6
Check Time33.44s (± 0.40%)33.46s (± 0.26%)~33.36s33.56sp=0.810 n=6
Emit Time2.67s (± 2.07%)2.71s (± 1.34%)~2.67s2.77sp=0.297 n=6
Total Time42.96s (± 0.42%)43.02s (± 0.28%)~42.87s43.14sp=0.378 n=6
self-compiler - node (v18.15.0, x64)
Memory used419,725k (± 0.01%)419,729k (± 0.01%)~419,699k419,754kp=0.630 n=6
Parse Time2.73s (± 3.81%)2.75s (± 3.06%)~2.66s2.85sp=0.518 n=6
Bind Time1.15s (± 7.04%)1.15s (± 6.72%)~1.07s1.23sp=0.869 n=6
Check Time15.10s (± 0.30%)15.11s (± 0.21%)~15.05s15.14sp=0.808 n=6
Emit Time1.16s (± 1.17%)1.16s (± 1.92%)~1.13s1.19sp=0.744 n=6
Total Time20.15s (± 0.18%)20.16s (± 0.15%)~20.12s20.21sp=0.370 n=6
vscode - node (v18.15.0, x64)
Memory used2,807,126k (± 0.00%)2,807,124k (± 0.00%)~2,807,029k2,807,194kp=0.748 n=6
Parse Time10.61s (± 0.32%)10.63s (± 0.54%)~10.54s10.71sp=0.332 n=6
Bind Time3.38s (± 0.47%)3.38s (± 0.39%)~3.37s3.40sp=0.655 n=6
Check Time59.81s (± 0.42%)59.82s (± 0.51%)~59.39s60.13sp=0.936 n=6
Emit Time16.14s (± 0.15%)16.15s (± 0.50%)~16.03s16.26sp=0.630 n=6
Total Time89.95s (± 0.26%)89.99s (± 0.26%)~89.58s90.16sp=0.520 n=6
webpack - node (v18.15.0, x64)
Memory used392,462k (± 0.02%)392,452k (± 0.01%)~392,411k392,504kp=0.810 n=6
Parse Time3.05s (± 1.39%)3.04s (± 0.78%)~3.00s3.07sp=0.742 n=6
Bind Time1.40s (± 0.70%)1.40s (± 0.58%)~1.39s1.41sp=0.604 n=6
Check Time13.95s (± 0.36%)13.99s (± 0.32%)~13.94s14.05sp=0.172 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time18.39s (± 0.39%)18.43s (± 0.29%)~18.38s18.51sp=0.297 n=6
xstate - node (v18.15.0, x64)
Memory used513,403k (± 0.01%)513,392k (± 0.01%)~513,348k513,429kp=0.298 n=6
Parse Time3.28s (± 0.23%)3.28s (± 0.43%)~3.26s3.30sp=0.867 n=6
Bind Time1.54s (± 0.00%)1.54s (± 0.33%)~1.54s1.55sp=0.174 n=6
Check Time2.84s (± 0.47%)2.85s (± 0.62%)~2.82s2.86sp=0.564 n=6
Emit Time0.08s (± 4.99%)0.08s (± 4.99%)~0.08s0.09sp=1.000 n=6
Total Time7.75s (± 0.24%)7.74s (± 0.31%)~7.70s7.77sp=0.607 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top-repos suite comparing main and refs/pull/57122/merge:

Something interesting changed - please have a look.

Details

chakra-ui/chakra-ui

4 of 28 projects failed to build with the old tsc and were ignored

packages/components/tsconfig.build.json

  • error TS5056: Cannot write file '/mnt/ts_downloads/chakra-ui/packages/components/dist/types/menu/menu.stories.d.ts' because it would be overwritten by multiple input files.
    • Project Scope

const target = (type.target ?? type) as MappedType;
const typeVariable = getHomomorphicTypeVariable(target);
if (typeVariable && !target.declaration.nameType) {
const constraint = getConstraintTypeFromMappedType(type);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All of this makes sense now... it is tricky that mapped types don't have constraints resolvable by getBaseConstraintOfType and such but we can reach for getConstraintTypeFromMappedType and use that.

const typeVariable = getHomomorphicTypeVariable(target);
if (typeVariable && !target.declaration.nameType) {
const constraint = getConstraintTypeFromMappedType(type);
if (constraint.flags & TypeFlags.Index) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if this check shouldn't be replaced with an assert - it's quite a strong invariant that this branch can only be entered after getHomomorphicTypeVariable returns true and that requires the constraint to be an Index type.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

An assert here wouldn't be right. There many cases where an instantiation of a homomorphic mapped type doesn't have a keyof XXX constraint anymore. For example, the homomorphic Readonly<T> has the constraint type keyof T, but the instantiation Readonly<{ a: string, b: string }> has the constraint type "a" | "b". What we're looking for here are instantiations where the constraint type is still a keyof XXX. That's what wasn't handled before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the explanation - it makes sense, getHomomorphicTypeVariable is called now with the target and not the type after all.

@Andarist

Mateusz Burzyński (Andarist) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

For what it's worth - I spent some sleepless nights on this last week so I built up some good context around this issue. LGTM (pending the resolution of #50034 ).

@gabritto

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 22, 2024

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/159624/artifacts?artifactName=tgz&fileId=C49A8E55A05E919674BFB05C151C2461B3DCB587EA33BD5BEF7FADC7C7A5BDD802&fileName=/typescript-5.4.0-insiders.20240122.tgz"
}
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.4.0-pr-57122-12".;


type Curry<F extends ((...args: any) => any)> =
<T extends any[]>(...args: Tools.Cast<Tools.Cast<T, Gaps<Parameters<F>>>, any[]>) =>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.

How is the change in the PR causing this error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe the underlying issue is the same as it was in my PRs. This is now resolved through layers and thus getResolvedApparentTypeOfMappedType sees the constraint of Parameters<F> - that once gets computed as unknown[] (by getDefaultConstraintOfConditionalType when restrictive instantiation bails out from getConstraintOfDistributiveConditionalType) and once as any (by getConstraintOfDistributiveConditionalType). So any can get returned and getResolvedApparentTypeOfMappedType can't recognize this as an array-like. So it ends up not d about it not being assignable to readonly any[] (that is being checked to determine if the type can be used as rest).

IIRC the other case (when unknown[]) is returned makes any[] (added by this Cast) eliminated from the substitution type since, at that point, it's determined that the baseType satisfies the added constraint - so the baseType gets returned.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So the issue is mainly in the fact that previously the substitution type wasn't simplified at all here and that & any[] in it (coming from its added constraint) was preserved and made the comparison against readonly any[] OK.

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.

What do you mean by "this is now resolved through layers"?
How do we go from a call to getResolvedApparentTypeOfMappedType to calls to getDefaultConstraintOfConditionalType and getConstraintOfDistributiveConditionalType?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please note that I'm partially speaking based on what I remember about debugging this last week - so some details might be slightly off.

Gaps is a mapped type - so we enter getResolvedApparentTypeOfMappedType. With this PR we recognize that an instantiation of a homomorphic mapped type is received and we end up checking its constraint and if it's an index type. It turns out it is because it's something like keyof Parameters<...>. So we grab the .type and compute its base constraint. So now we are computing the constraint of a conditional type (through getConstraintFromConditionalType) and, as mentioned above, this once resolves through getDefaultConstraintOfConditionalType (for the restrictive instantiation case) and once through getConstraintOfDistributiveConditionalType (for a regular case :P).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

With latest commit this error is gone.

@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Feb 16, 2024

Copy link
Copy Markdown
MemberAuthor

Latest PR incorporates the changes in #50034, plus an additional change to fix this inconsistency:

functionfoo<Textendsstring[]>(fa: (s: string, ...args: string[])=>string,fb: (s: string, ...args: T)=>string){constf1: (...args: any)=>string=fa;// Okconstf2: (...args: any[])=>string=fa;// Okconstf3: (...args: any)=>string=fb;// Okconstf4: (...args: any[])=>string=fb;// Error}

Before this PR, the assignment to f4 was an error, which is inconsistent with f2. With #50034, both of f3 and f4 become errors, which also isn't right. With the latest commit, all of the above are now ok.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user test suite comparing main and refs/pull/57122/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 16, 2024

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/159926/artifacts?artifactName=tgz&fileId=0CB616DD206446C008D255DF90ECB91D8A3A7FB7F44F73B0AD2F06AA1FE1696202&fileName=/typescript-5.4.0-insiders.20240216.tgz"
}
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.4.0-pr-57122-21".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), the results of running the DT tests are ready.
There were interesting changes:

Branch only errors:

Package: lodash
Error:

Error: /home/vsts/work/1/DefinitelyTyped/types/lodash/common/function.d.ts
1414:34 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
1420:39 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
/home/vsts/work/1/DefinitelyTyped/types/lodash/common/util.d.ts
313:71 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
317:67 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
321:63 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
325:59 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
329:55 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
333:56 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
343:71 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
347:67 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
351:63 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
355:59 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
359:55 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
363:56 error TypeScript@local compile error: Type '"0"' cannot be used to index type 'Parameters<T>' @definitelytyped/expect
✖ 14 problems (14 errors, 0 warnings)
at combineErrorsAndWarnings (/home/vsts/work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.10_typescript@5.4.0-dev.20240216/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
at runTests (/home/vsts/work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.10_typescript@5.4.0-dev.20240216/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top-repos suite comparing main and refs/pull/57122/merge:

Something interesting changed - please have a look.

Details

ReactiveX/rxjs

11 of 15 projects failed to build with the old tsc and were ignored

packages/rxjs/src/tsconfig.types.json

vercel/hyper

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2536: Type '"0"' cannot be used to index type 'Parameters<T>'.
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/function.d.ts#L1414 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/function.d.ts#L1420 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L313 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L317 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L321 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L325 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L329 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L333 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L343 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L347 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L351 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L355 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L359 in app/tsconfig.json
    • file:///mnt/ts_downloads/hyper/node_modules/@types/lodash/common/util.d.ts#L363 in app/tsconfig.json

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

The test runs reveal inconsistencies related to indexing arrays with numeric string literals (as in #50034):

functionbar<Textendsstring[],Kextendsnumber>(){typeT00=string[]["0"];// OktypeT01=string[]["0.0"];// Error, as expectedtypeT02=string[][K|"0"];// Error, but shouldn't betypeT10=T["0"];// Error, but shouldn't betypeT11=T["0.0"];// Error, as expectedtypeT12=T[K|"0"];// Error, but shouldn't be}

The errors on T01 and T11 are expected because the numeric string literal doesn't round-trip (i.e. when converted to number and back to string, it yields a different representation). However, T02, T10, and T12 shouldn't error and I will fix that. Regardless of the fix, I don't think we want to include `${number}` in the index type for types that have a number index signature. First, it isn't quite correct because `${number}` doesn't require matching strings to round-trip, and second, it is a breaking change that I'd rather avoid. I think the best place to land is simply a targeted fix to make indexing with round-tripping numeric strings consistent as per the example above.

@typescript-botTypeScript Bot (typescript-bot) added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Backlog Bug PRs that fix a backlog bug labels Feb 18, 2024
@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 18, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based top-repos suite on this PR at 633bfc3. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 18, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 633bfc3. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 18, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at 633bfc3. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Feb 18, 2024

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the faster perf test suite on this PR at 633bfc3. You can monitor the build here.

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user test suite comparing main and refs/pull/57122/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Angular - node (v18.15.0, x64)
Memory used295,653k (± 0.01%)295,657k (± 0.01%)~295,622k295,690kp=1.000 n=6
Parse Time2.66s (± 0.39%)2.66s (± 0.37%)~2.65s2.67sp=0.452 n=6
Bind Time0.84s (± 1.50%)0.83s (± 0.91%)~0.82s0.84sp=0.115 n=6
Check Time8.26s (± 0.24%)8.25s (± 0.47%)~8.19s8.30sp=0.935 n=6
Emit Time7.09s (± 0.26%)7.10s (± 0.32%)~7.07s7.14sp=0.224 n=6
Total Time18.85s (± 0.05%)18.84s (± 0.29%)~18.74s18.89sp=0.936 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used193,019k (± 1.28%)193,517k (± 1.53%)~191,576k197,372kp=1.000 n=6
Parse Time1.35s (± 0.81%)1.37s (± 1.13%)+0.02s (+ 1.48%)1.35s1.38sp=0.034 n=6
Bind Time0.72s (± 0.00%)0.72s (± 0.00%)~0.72s0.72sp=1.000 n=6
Check Time9.38s (± 0.50%)9.41s (± 1.00%)~9.32s9.59sp=0.521 n=6
Emit Time2.61s (± 0.45%)2.61s (± 0.58%)~2.59s2.63sp=0.805 n=6
Total Time14.06s (± 0.32%)14.11s (± 0.70%)~13.98s14.28sp=0.293 n=6
Monaco - node (v18.15.0, x64)
Memory used347,472k (± 0.01%)347,470k (± 0.01%)~347,447k347,498kp=1.000 n=6
Parse Time2.48s (± 0.33%)2.48s (± 0.51%)~2.46s2.49sp=0.796 n=6
Bind Time0.93s (± 0.81%)0.93s (± 0.44%)~0.92s0.93sp=1.000 n=6
Check Time6.95s (± 0.55%)6.94s (± 0.28%)~6.93s6.98sp=0.686 n=6
Emit Time4.04s (± 0.34%)4.06s (± 0.34%)~4.04s4.08sp=0.241 n=6
Total Time14.40s (± 0.24%)14.40s (± 0.28%)~14.35s14.47sp=1.000 n=6
TFS - node (v18.15.0, x64)
Memory used302,861k (± 0.01%)302,881k (± 0.01%)~302,856k302,910kp=0.109 n=6
Parse Time2.01s (± 0.92%)2.01s (± 1.03%)~1.98s2.04sp=0.567 n=6
Bind Time1.00s (± 1.03%)1.00s (± 1.03%)~0.99s1.02sp=1.000 n=6
Check Time6.36s (± 0.13%)6.36s (± 0.17%)~6.34s6.37sp=0.652 n=6
Emit Time3.59s (± 0.46%)3.58s (± 0.53%)~3.55s3.60sp=0.804 n=6
Total Time12.96s (± 0.18%)12.95s (± 0.18%)~12.92s12.98sp=0.416 n=6
material-ui - node (v18.15.0, x64)
Memory used511,275k (± 0.01%)511,315k (± 0.01%)~511,263k511,467kp=0.378 n=6
Parse Time2.66s (± 0.44%)2.65s (± 0.81%)~2.62s2.67sp=0.315 n=6
Bind Time0.99s (± 0.52%)0.99s (± 0.90%)~0.98s1.00sp=0.541 n=6
Check Time17.25s (± 0.47%)17.27s (± 0.51%)~17.16s17.34sp=0.936 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.90s (± 0.35%)20.91s (± 0.46%)~20.77s21.01sp=0.809 n=6
mui-docs - node (v18.15.0, x64)
Memory used2,272,227k (± 0.00%)2,271,775k (± 0.00%)-452k (- 0.02%)2,271,749k2,271,799kp=0.005 n=6
Parse Time11.96s (± 0.77%)12.04s (± 0.91%)~11.88s12.18sp=0.199 n=6
Bind Time2.62s (± 0.29%)2.62s (± 0.20%)~2.62s2.63sp=0.784 n=6
Check Time102.63s (± 0.90%)101.38s (± 0.85%)-1.25s (- 1.21%)100.03s102.42sp=0.045 n=6
Emit Time0.32s (± 0.00%)0.32s (± 1.27%)~0.32s0.33sp=0.405 n=6
Total Time117.53s (± 0.83%)116.37s (± 0.81%)~114.87s117.54sp=0.093 n=6
self-build-src - node (v18.15.0, x64)
Memory used2,412,996k (± 0.02%)2,413,466k (± 0.02%)~2,412,685k2,414,166kp=0.128 n=6
Parse Time4.94s (± 1.21%)4.94s (± 0.79%)~4.89s4.99sp=0.688 n=6
Bind Time1.86s (± 0.65%)1.88s (± 0.29%)+0.01s (+ 0.63%)1.87s1.88sp=0.038 n=6
Check Time33.51s (± 0.28%)33.52s (± 0.50%)~33.30s33.75sp=0.936 n=6
Emit Time2.69s (± 1.54%)2.66s (± 1.15%)~2.63s2.71sp=0.170 n=6
Total Time43.03s (± 0.23%)43.01s (± 0.43%)~42.72s43.24sp=0.936 n=6
self-compiler - node (v18.15.0, x64)
Memory used418,843k (± 0.03%)418,967k (± 0.01%)~418,927k419,004kp=0.066 n=6
Parse Time2.80s (± 2.59%)2.79s (± 2.21%)~2.67s2.84sp=0.514 n=6
Bind Time1.10s (± 5.11%)1.10s (± 5.27%)~1.07s1.22sp=0.445 n=6
Check Time15.16s (± 0.31%)15.21s (± 0.23%)~15.16s15.24sp=0.065 n=6
Emit Time1.13s (± 0.91%)1.14s (± 1.11%)~1.13s1.16sp=0.391 n=6
Total Time20.19s (± 0.20%)20.24s (± 0.21%)~20.18s20.30sp=0.127 n=6
vscode - node (v18.15.0, x64)
Memory used2,844,942k (± 0.00%)2,845,771k (± 0.00%)+829k (+ 0.03%)2,845,731k2,845,853kp=0.005 n=6
Parse Time10.74s (± 0.39%)10.75s (± 0.27%)~10.72s10.79sp=0.809 n=6
Bind Time3.44s (± 0.37%)3.43s (± 0.48%)~3.41s3.45sp=0.565 n=6
Check Time60.39s (± 0.47%)60.71s (± 0.49%)~60.37s61.18sp=0.093 n=6
Emit Time16.35s (± 0.70%)16.29s (± 0.57%)~16.16s16.44sp=0.377 n=6
Total Time90.92s (± 0.23%)91.18s (± 0.37%)~90.79s91.66sp=0.261 n=6
webpack - node (v18.15.0, x64)
Memory used394,115k (± 0.02%)394,202k (± 0.01%)~394,159k394,293kp=0.093 n=6
Parse Time3.11s (± 0.47%)3.12s (± 0.24%)~3.11s3.13sp=0.241 n=6
Bind Time1.38s (± 0.92%)1.39s (± 1.17%)~1.37s1.41sp=0.163 n=6
Check Time14.09s (± 0.52%)14.08s (± 0.32%)~14.01s14.13sp=0.872 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time18.58s (± 0.36%)18.59s (± 0.31%)~18.51s18.67sp=0.872 n=6
xstate - node (v18.15.0, x64)
Memory used513,356k (± 0.01%)513,443k (± 0.02%)~513,338k513,650kp=0.128 n=6
Parse Time3.27s (± 0.25%)3.27s (± 0.32%)~3.26s3.29sp=0.932 n=6
Bind Time1.54s (± 0.33%)1.54s (± 0.49%)~1.53s1.55sp=0.784 n=6
Check Time2.85s (± 0.87%)2.87s (± 0.68%)~2.85s2.90sp=0.332 n=6
Emit Time0.08s (± 4.99%)0.08s (± 0.00%)~0.08s0.08sp=0.405 n=6
Total Time7.76s (± 0.34%)7.77s (± 0.27%)~7.74s7.80sp=0.517 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

Comment on lines +16 to +23
function bar<T extends string[], K extends number>() {
type T00 = string[]["0"];
type T01 = string[]["0.0"]; // Error
type T02 = string[][K | "0"];
type T10 = T["0"];
type T11 = T["0.0"]; // Error
type T12 = T[K | "0"];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: those should likely be in a different test file since they don't have anything in common with this "test title" (assignmentToAnyArrayRestParameters)

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top-repos suite comparing main and refs/pull/57122/merge:

Everything looks good!

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

Test and performance suites are all clean. This is ready to merge.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Milestone BugPRs that fix a bug with a specific milestone

Projects

Archived in project

5 participants

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