Skip to content

Conversation

@Andarist
Copy link
Contributor

@AndaristAndarist commented Jan 22, 2025

fixes#60988 , it fixes a regression from #57403 that was not addressed by #58168 , cc @weswigham

fixes#61090

@typescript-bottypescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 22, 2025
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 22, 2025

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started👀 Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/61013/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3434~~~p=1.000 n=6
Symbols62,39062,390~~~p=1.000 n=6
Types50,39550,395~~~p=1.000 n=6
Memory used196,755k (± 0.13%)195,667k (± 0.93%)~193,315k196,979kp=0.378 n=6
Parse Time1.61s (± 1.22%)1.61s (± 0.82%)~1.59s1.63sp=0.741 n=6
Bind Time0.88s (± 1.51%)0.88s (± 1.56%)~0.86s0.90sp=0.452 n=6
Check Time11.83s (± 0.53%)11.78s (± 0.57%)~11.67s11.88sp=0.199 n=6
Emit Time3.34s (± 2.72%)3.30s (± 0.74%)~3.27s3.33sp=0.624 n=6
Total Time17.66s (± 0.71%)17.57s (± 0.37%)~17.48s17.64sp=0.226 n=6
angular-1 - node (v18.15.0, x64)
Errors3737~~~p=1.000 n=6
Symbols948,492948,492~~~p=1.000 n=6
Types411,004411,004~~~p=1.000 n=6
Memory used1,225,498k (± 0.00%)1,225,499k (± 0.01%)~1,225,426k1,225,645kp=0.936 n=6
Parse Time8.02s (± 0.79%)8.02s (± 0.76%)~7.94s8.10sp=0.872 n=6
Bind Time2.31s (± 0.42%)2.29s (± 0.53%)-0.02s (- 0.72%)2.28s2.31sp=0.048 n=6
Check Time38.30s (± 0.54%)38.37s (± 0.50%)~38.04s38.56sp=0.378 n=6
Emit Time18.23s (± 0.38%)18.32s (± 0.53%)~18.16s18.42sp=0.109 n=6
Total Time66.86s (± 0.41%)67.01s (± 0.30%)~66.64s67.20sp=0.229 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,444,9102,444,910~~~p=1.000 n=6
Types896,791896,791~~~p=1.000 n=6
Memory used2,303,627k (± 0.00%)2,303,578k (± 0.01%)~2,303,349k2,303,748kp=0.810 n=6
Parse Time10.77s (± 0.64%)10.78s (± 0.67%)~10.64s10.84sp=0.810 n=6
Bind Time2.60s (± 0.94%)2.63s (± 0.57%)~2.60s2.64sp=0.050 n=6
Check Time89.46s (± 1.94%)89.39s (± 1.73%)~87.72s91.19sp=1.000 n=6
Emit Time0.35s (± 1.59%)0.69s (±121.40%)~0.34s2.39sp=0.476 n=6
Total Time103.18s (± 1.63%)103.48s (± 1.33%)~101.53s104.95sp=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,228,7921,228,793+1 (+ 0.00%)~~p=0.001 n=6
Types266,906266,905-1 (- 0.00%)~~p=0.001 n=6
Memory used3,092,401k (± 0.01%)2,727,494k (±14.62%)🟩-364,907k (-11.80%)2,362,288k3,092,514kp=0.020 n=6
Parse Time6.80s (± 0.83%)6.71s (± 1.57%)~6.58s6.83sp=0.230 n=6
Bind Time2.12s (± 2.08%)2.17s (± 1.51%)~2.11s2.20sp=0.065 n=6
Check Time42.99s (± 0.30%)42.72s (± 0.29%)-0.26s (- 0.61%)42.55s42.90sp=0.008 n=6
Emit Time3.47s (± 1.59%)3.53s (± 2.29%)~3.46s3.67sp=0.230 n=6
Total Time55.40s (± 0.26%)55.14s (± 0.28%)-0.26s (- 0.47%)54.98s55.36sp=0.016 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,228,7921,228,793+1 (+ 0.00%)~~p=0.001 n=6
Types266,906266,905-1 (- 0.00%)~~p=0.001 n=6
Memory used2,794,341k (±14.22%)3,037,093k (± 9.74%)~2,432,790k3,158,401kp=0.128 n=6
Parse Time8.56s (± 1.52%)8.63s (± 0.96%)~8.47s8.69sp=0.336 n=6
Bind Time2.66s (± 2.03%)2.65s (± 1.54%)~2.58s2.70sp=0.575 n=6
Check Time53.02s (± 0.61%)53.16s (± 0.38%)~52.94s53.45sp=0.575 n=6
Emit Time4.27s (± 2.34%)4.32s (± 2.52%)~4.19s4.48sp=0.471 n=6
Total Time68.51s (± 0.61%)68.76s (± 0.47%)~68.32s69.21sp=0.298 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols262,659262,660+1 (+ 0.00%)~~p=0.001 n=6
Types106,711106,710-1 (- 0.00%)~~p=0.001 n=6
Memory used440,865k (± 0.02%)440,873k (± 0.02%)~440,762k441,007kp=1.000 n=6
Parse Time3.53s (± 0.73%)3.55s (± 0.78%)~3.50s3.57sp=0.145 n=6
Bind Time1.32s (± 1.25%)1.31s (± 0.64%)~1.29s1.31sp=0.218 n=6
Check Time19.02s (± 0.50%)18.96s (± 0.48%)~18.82s19.04sp=0.199 n=6
Emit Time1.55s (± 0.97%)1.53s (± 0.72%)-0.02s (- 1.50%)1.52s1.55sp=0.018 n=6
Total Time25.41s (± 0.41%)25.34s (± 0.39%)~25.18s25.43sp=0.227 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors7070~~~p=1.000 n=6
Symbols226,113226,113~~~p=1.000 n=6
Types94,48894,488~~~p=1.000 n=6
Memory used371,733k (± 0.02%)371,773k (± 0.03%)~371,636k372,003kp=0.810 n=6
Parse Time2.89s (± 0.97%)2.90s (± 1.28%)~2.85s2.96sp=0.871 n=6
Bind Time1.61s (± 1.51%)1.60s (± 2.16%)~1.57s1.66sp=0.418 n=6
Check Time16.47s (± 0.35%)16.50s (± 0.62%)~16.36s16.64sp=0.810 n=6
Emit Time0.00s (±244.70%)0.00s~~~p=0.405 n=6
Total Time20.97s (± 0.37%)21.00s (± 0.58%)~20.79s21.12sp=0.630 n=6
vscode - node (v18.15.0, x64)
Errors33~~~p=1.000 n=6
Symbols3,262,9293,262,929~~~p=1.000 n=6
Types1,122,0551,122,055~~~p=1.000 n=6
Memory used3,336,525k (± 0.00%)3,336,537k (± 0.01%)~3,336,018k3,336,789kp=0.689 n=6
Parse Time14.50s (± 0.64%)14.58s (± 0.70%)~14.46s14.71sp=0.172 n=6
Bind Time4.58s (± 0.23%)4.56s (± 0.43%)~4.53s4.58sp=0.084 n=6
Check Time88.55s (± 1.52%)89.69s (± 3.16%)~87.65s95.01sp=0.575 n=6
Emit Time27.00s (± 7.85%)26.82s (± 7.55%)~22.92s28.93sp=0.471 n=6
Total Time134.62s (± 0.73%)135.65s (± 1.38%)~133.84s138.76sp=0.575 n=6
webpack - node (v18.15.0, x64)
Errors01🔻+1 (+ ∞%)~~p=0.001 n=6
Symbols292,550292,643+93 (+ 0.03%)~~p=0.001 n=6
Types119,124119,168+44 (+ 0.04%)~~p=0.001 n=6
Memory used446,032k (± 0.03%)446,133k (± 0.03%)~445,914k446,207kp=0.199 n=6
Parse Time4.05s (± 1.52%)4.07s (± 0.37%)~4.05s4.08sp=0.745 n=6
Bind Time1.76s (± 0.93%)1.79s (± 0.84%)+0.03s (+ 1.70%)1.77s1.81sp=0.019 n=6
Check Time18.80s (± 0.99%)19.04s (± 2.15%)~18.79s19.87sp=0.748 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time24.62s (± 0.75%)24.91s (± 1.63%)~24.65s25.73sp=0.173 n=6
xstate-main - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols555,376555,376~~~p=1.000 n=6
Types186,151186,151~~~p=1.000 n=6
Memory used494,406k (± 0.02%)494,394k (± 0.01%)~494,345k494,441kp=0.810 n=6
Parse Time2.76s (± 0.30%)2.77s (± 0.20%)~2.76s2.77sp=0.859 n=6
Bind Time0.96s (± 0.42%)0.96s (± 0.57%)~0.96s0.97sp=0.282 n=6
Check Time16.32s (± 0.26%)16.30s (± 0.26%)~16.23s16.35sp=0.747 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time20.04s (± 0.20%)20.03s (± 0.20%)~19.97s20.07sp=0.872 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/61013/merge:

Everything looks good!

// so our inference results for this call doesn't pollute expression types referencing the outer type parameter!
const paramLocation = candidate.typeParameters[0].symbol.declarations?.[0]?.parent;
const candidateParameterContext = paramLocation || (candidate.declaration && isConstructorDeclaration(candidate.declaration) ? candidate.declaration.parent : candidate.declaration);
const paramHost = getEffectiveTypeParameterHost(candidate.typeParameters[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually use the term "host" like this elsewhere?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I guess "host" might only be appropriate in the JSDoc context but I don't have a better name for this that would cover both TS and JSDoc-based types

Copy link
Member

Choose a reason for hiding this comment

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

I mean "context" is what the PR title and the code below uses; could technically just inline it too. But, the existing JSDoc func used the term, so it's probably okay.

@Andarist
Copy link
ContributorAuthor

Andarist commented Jan 22, 2025

Regarding this reported change. I don't quite know on the spot why this has changed but it looks like a correct change. At the very least the new behavior matches existing TS behavior. See those 2: JS playground and TS playground. It also looks like the original intention of this cast was a non-null-like assertion but accidentally [] were forgotten?

EDIT: this error was reported in TS 5.4 (TS playground) so that just assures me it's the "new" behavior is the correct one :p

function getEffectiveTypeParameterHost(typeParameter: TypeParameter){
const tp = getDeclarationOfKind<TypeParameterDeclaration>(typeParameter.symbol, SyntaxKind.TypeParameter)!;
const host = isJSDocTemplateTag(tp.parent) ? getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent;
return isJSDocTemplateTag(tp.parent) ? getEffectiveJSDocHost(tp.parent) : tp.parent;
Copy link
Member

Choose a reason for hiding this comment

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

This sort of makes me wonder when we really should be using getEffectiveJSDocHost where we are currently using getEffectiveContainerForJSDocTemplateTag...

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Right, but to be fair - I had to use getEffectiveJSDocHost to fix this issue at hand and it didn't look to me like this older function would have to stick to the other one. There is a chance that it should not use this - but there is also a chance that this change fixed some other issue ;p

In the ideal world, I'd go through all of the callers to both and assess their needs but I just don't have time to do that right now 😢

@jakebailey
Copy link
Member

Regarding this reported change. I don't quite know on the spot why this has changed but it looks like a correct change. At the very least the new behavior matches existing TS behavior. See those 2: JS playground and TS playground. It also looks like the original intention of this cast was a non-null-like assertion but accidentally [] were forgotten?

EDIT: this error was reported in TS 5.4 (TS playground) so that just assures me it's the "new" behavior is the correct one :p

The thing I'm most confused about is that it says []any; why is it any? Just because it's T &?

@Andarist
Copy link
ContributorAuthor

The thing I'm most confused about is that it says []any; why is it any? Just because it's T &?

It fails to infer it completely so it uses the default for an unconstrained type parameter. It happens that in JS files it's any and in TS files it's unknown.

@typescript-bottypescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 31, 2025
@AndaristAndarist changed the title Use better context scope for class constructor implementation signatures in JS filesUse proper type parameter hosts in JS filesJan 31, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog BugPRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

JSDOC generics bug for callbacks when args are present JSDoc recursive inference not working properly on generic array wrapping

3 participants

@Andarist@jakebailey@typescript-bot