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

Fixed generic inference when the contextual type is a signature with properties #52495

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixed #52262

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jan 30, 2023
@@ -36975,7 +36975,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (signature && signature.typeParameters) {
const contextualType = getApparentTypeOfContextualType(node as Expression, ContextFlags.NoConstraints);
if (contextualType) {
const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ false);
const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a little bit hesitant to say that I'm 100% confident in this fix. I'm pretty sure that it's on the right track but there is a chance that it needs some further polish to handle cases in which the generics are used both in the signature and in those extra properties on the type.

This change satisfies the whole existing test suite but mixing signatures with extra properties isn't the most popular technique. So I'm a little bit worried that the existing test suite might not capture some requirements. Gonna investigate this sometime later.

Copy link
Member

Choose a reason for hiding this comment

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

History found, explanation for current behavior here. If you want to toggle this boolean (and I can see why), you need to validate the other members don't reference the type parameters we want to promote to the signature. That's pretty hard, so a reasonable proxy is checking that the other members of the type don't reference any type variables at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented the suggested change - could you take another look at this?

@@ -36975,7 +36975,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (signature && signature.typeParameters) {
const contextualType = getApparentTypeOfContextualType(node as Expression, ContextFlags.NoConstraints);
if (contextualType) {
const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ false);
const contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? SignatureKind.Call : SignatureKind.Construct, /*allowMembers*/ true);
Copy link
Member

Choose a reason for hiding this comment

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

History found, explanation for current behavior here. If you want to toggle this boolean (and I can see why), you need to validate the other members don't reference the type parameters we want to promote to the signature. That's pretty hard, so a reasonable proxy is checking that the other members of the type don't reference any type variables at all.

@weswigham
Copy link
Member

@typescript-bot test this
@typescript-bot run dt
@typescript-bot test top100
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 57eb903. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @weswigham, I've started to run the perf test suite on this PR at 57eb903. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 20, 2023

Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 57eb903. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

Heya @weswigham, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

ant-design/ant-design

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

tsconfig.json

  • error TS2345: Argument of type '<OptionType extends BaseOptionType | DefaultOptionType = BaseOptionType>({ prefixCls: customizePrefixCls, size: customizeSize, disabled: customDisabled, bordered, className, rootClassName, treeCheckable, multiple, listHeight, listItemHeight, placement, notFoundContent, switcherIcon, treeLine, getPopupContainer, popu...' is not assignable to parameter of type 'ForwardRefRenderFunction<BaseSelectRef, TreeSelectProps<ValueType, OptionType> & { children?: ReactNode; } & { ref?: Ref<BaseSelectRef> | undefined; }>'.

microsoft/vscode

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

src/tsconfig.tsec.json

react-bootstrap/react-bootstrap

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

tsconfig.json

  • error TS2322: Type 'ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & DropdownItemProps> & BsPrefixProps<As> & DropdownItemProps & { ...; }> & RefAttributes<...>>' is not assignable to type 'BsPrefixRefForwardingComponent<DynamicRefForwardingComponent<ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLElement>>, DropdownItemProps>, DropdownItemProps>'.
  • error TS2604: JSX element type 'Component' does not have any construct or call signatures.
  • error TS2322: Type 'ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & FeedbackProps> & BsPrefixProps<As> & FeedbackProps & { ...; }> & RefAttributes<...>>' is not assignable to type 'BsPrefixRefForwardingComponent<"div", FeedbackProps>'.
  • error TS2322: Type 'ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & FloatingLabelProps> & BsPrefixProps<As> & FloatingLabelProps & { ...; }> & RefAttributes<...>>' is not assignable to type 'BsPrefixRefForwardingComponent<"div", FloatingLabelProps>'.
  • error TS2322: Type '{ ref: ForwardedRef<unknown>; className: string; controlId: string | undefined; } & Omit<PropsWithChildren<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & FloatingLabelProps> & BsPrefixProps<...> & FloatingLabelProps & { ...; }>, "className" | ... 3 more ... | "controlId"> & { ...; }' is not assignable to type 'IntrinsicAttributes & Omit<ComponentPropsWithRef<PropsWithChildren<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & FloatingLabelProps> & BsPrefixProps<...> & FloatingLabelProps & { ...; }>["as"]>, BsPrefixProps<...> & FormGroupProps> & BsPrefixProps<...> & FormGroupProps & { ...; }'.
  • error TS2322: Type 'ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & FormGroupProps> & BsPrefixProps<As> & FormGroupProps & { ...; }> & RefAttributes<...>>' is not assignable to type 'BsPrefixRefForwardingComponent<"div", FormGroupProps>'.
  • error TS2322: Type 'ForwardRefExoticComponent<PropsWithoutRef<Omit<ComponentPropsWithRef<As>, BsPrefixProps<As> & ModalProps> & BsPrefixProps<As> & ModalProps & { ...; }> & RefAttributes<...>>' is not assignable to type 'BsPrefixRefForwardingComponent<"div", ModalProps>'.

yangshun/tech-interview-handbook

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

packages/ui/tsconfig.json

  • error TS2345: Argument of type '<T>({ borderStyle, defaultValue, display, disabled, errorMessage, label, isLabelHidden, options, placeholder, required, value, onChange, ...props }: Props<T>, ref: ForwardedRef<HTMLSelectElement>) => Element' is not assignable to parameter of type 'ForwardRefRenderFunction<unknown, {}>'.

@weswigham
Copy link
Member

@Andarist looks like there's a fair bit going on in the top100 suite to look into for this one. Maybe related to eagerly producing more of the type structure to check for type variable presence?

@typescript-bot
Copy link
Collaborator

Hey @weswigham, it looks like the DT test run failed. Please check the log for more details.
You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..52495
Metric main 52495 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 361,719k (± 0.01%) 363,022k (± 0.01%) +1,302k (+ 0.36%) 362,961k 363,087k p=0.005 n=6
Parse Time 3.38s (± 0.76%) 3.37s (± 0.35%) ~ 3.36s 3.39s p=0.569 n=6
Bind Time 1.11s (± 0.89%) 1.12s (± 1.04%) ~ 1.11s 1.14s p=0.181 n=6
Check Time 8.64s (± 0.24%) 8.77s (± 0.41%) +0.13s (+ 1.49%) 8.73s 8.83s p=0.005 n=6
Emit Time 7.45s (± 0.73%) 7.44s (± 1.04%) ~ 7.36s 7.56s p=0.872 n=6
Total Time 20.57s (± 0.31%) 20.70s (± 0.34%) +0.13s (+ 0.62%) 20.64s 20.83s p=0.016 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 193,678k (± 1.62%) 191,859k (± 1.22%) ~ 190,861k 196,640k p=0.810 n=6
Parse Time 1.50s (± 0.69%) 1.50s (± 0.78%) ~ 1.48s 1.51s p=0.615 n=6
Bind Time 0.78s (± 1.35%) 0.77s (± 0.53%) ~ 0.77s 0.78s p=0.528 n=6
Check Time 9.37s (± 0.73%) 9.38s (± 0.61%) ~ 9.30s 9.47s p=0.419 n=6
Emit Time 2.75s (± 0.90%) 2.73s (± 1.24%) ~ 2.71s 2.80s p=0.226 n=6
Total Time 14.40s (± 0.57%) 14.39s (± 0.37%) ~ 14.32s 14.45s p=1.000 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,272k (± 0.01%) 346,671k (± 0.01%) +399k (+ 0.12%) 346,631k 346,719k p=0.005 n=6
Parse Time 2.57s (± 0.93%) 2.60s (± 0.63%) ~ 2.58s 2.62s p=0.090 n=6
Bind Time 1.00s (± 0.41%) 1.01s (± 0.74%) +0.01s (+ 1.00%) 1.00s 1.02s p=0.029 n=6
Check Time 6.99s (± 0.60%) 7.02s (± 0.39%) ~ 7.00s 7.07s p=0.255 n=6
Emit Time 4.25s (± 1.15%) 4.23s (± 0.73%) ~ 4.19s 4.26s p=0.469 n=6
Total Time 14.82s (± 0.40%) 14.86s (± 0.45%) ~ 14.79s 14.95s p=0.470 n=6
TFS - node (v18.10.0, x64)
Memory used 300,476k (± 0.01%) 300,879k (± 0.01%) +403k (+ 0.13%) 300,838k 300,927k p=0.005 n=6
Parse Time 2.07s (± 1.07%) 2.07s (± 0.94%) ~ 2.05s 2.10s p=0.935 n=6
Bind Time 1.14s (± 0.45%) 1.14s (± 0.55%) ~ 1.13s 1.15s p=0.386 n=6
Check Time 6.49s (± 0.35%) 6.49s (± 0.76%) ~ 6.42s 6.55s p=0.628 n=6
Emit Time 3.87s (± 0.82%) 3.85s (± 1.03%) ~ 3.81s 3.92s p=0.377 n=6
Total Time 13.57s (± 0.28%) 13.55s (± 0.50%) ~ 13.47s 13.67s p=0.630 n=6
material-ui - node (v18.10.0, x64)
Memory used 477,142k (± 0.01%) 477,660k (± 0.01%) +518k (+ 0.11%) 477,586k 477,708k p=0.005 n=6
Parse Time 3.05s (± 3.00%) 3.02s (± 2.71%) ~ 2.92s 3.10s p=0.513 n=6
Bind Time 0.96s (± 8.47%) 0.99s (± 8.73%) ~ 0.90s 1.08s p=0.415 n=6
Check Time 16.85s (± 0.22%) 17.23s (± 0.46%) +0.38s (+ 2.24%) 17.13s 17.32s p=0.005 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.85s (± 0.20%) 21.23s (± 0.38%) +0.38s (+ 1.82%) 21.11s 21.33s p=0.005 n=6
xstate - node (v18.10.0, x64)
Memory used 552,932k (± 0.01%) 553,133k (± 0.02%) +201k (+ 0.04%) 553,055k 553,301k p=0.005 n=6
Parse Time 3.78s (± 0.59%) 3.78s (± 0.53%) ~ 3.75s 3.81s p=0.685 n=6
Bind Time 1.68s (± 0.84%) 1.69s (± 0.58%) ~ 1.68s 1.70s p=0.315 n=6
Check Time 2.80s (± 0.64%) 2.88s (± 0.75%) +0.08s (+ 2.98%) 2.85s 2.91s p=0.005 n=6
Emit Time 0.08s (± 4.99%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=0.405 n=6
Total Time 8.35s (± 0.48%) 8.43s (± 0.52%) +0.08s (+ 1.00%) 8.37s 8.48s p=0.024 n=6
Angular - node (v16.17.1, x64)
Memory used 361,061k (± 0.01%) 362,380k (± 0.01%) +1,319k (+ 0.37%) 362,318k 362,415k p=0.005 n=6
Parse Time 3.52s (± 0.28%) 3.54s (± 0.61%) ~ 3.51s 3.57s p=0.155 n=6
Bind Time 1.18s (± 0.64%) 1.18s (± 0.64%) ~ 1.17s 1.19s p=1.000 n=6
Check Time 9.44s (± 0.34%) 9.53s (± 0.55%) +0.09s (+ 0.94%) 9.47s 9.62s p=0.010 n=6
Emit Time 7.92s (± 1.04%) 7.92s (± 0.51%) ~ 7.88s 7.98s p=0.810 n=6
Total Time 22.05s (± 0.54%) 22.17s (± 0.18%) ~ 22.11s 22.21s p=0.124 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,684k (± 0.90%) 192,682k (± 0.04%) ~ 192,590k 192,798k p=0.471 n=6
Parse Time 1.57s (± 2.38%) 1.59s (± 0.47%) ~ 1.58s 1.60s p=0.368 n=6
Bind Time 0.82s (± 0.50%) 0.82s (± 0.77%) ~ 0.81s 0.83s p=0.673 n=6
Check Time 10.06s (± 0.50%) 10.07s (± 0.43%) ~ 10.02s 10.15s p=1.000 n=6
Emit Time 3.02s (± 0.86%) 3.01s (± 0.66%) ~ 2.97s 3.03s p=0.624 n=6
Total Time 15.46s (± 0.36%) 15.48s (± 0.37%) ~ 15.42s 15.58s p=0.336 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,552k (± 0.00%) 345,997k (± 0.01%) +445k (+ 0.13%) 345,966k 346,027k p=0.005 n=6
Parse Time 2.73s (± 0.68%) 2.74s (± 0.38%) ~ 2.72s 2.75s p=0.192 n=6
Bind Time 1.09s (± 0.90%) 1.09s (± 0.37%) ~ 1.09s 1.10s p=0.930 n=6
Check Time 7.71s (± 0.73%) 7.74s (± 0.49%) ~ 7.67s 7.77s p=0.468 n=6
Emit Time 4.45s (± 0.39%) 4.45s (± 0.68%) ~ 4.41s 4.50s p=0.416 n=6
Total Time 15.98s (± 0.57%) 16.01s (± 0.22%) ~ 15.97s 16.05s p=0.376 n=6
TFS - node (v16.17.1, x64)
Memory used 299,805k (± 0.01%) 300,206k (± 0.01%) +402k (+ 0.13%) 300,164k 300,253k p=0.005 n=6
Parse Time 2.17s (± 0.54%) 2.18s (± 1.08%) ~ 2.16s 2.21s p=0.680 n=6
Bind Time 1.24s (± 0.94%) 1.24s (± 0.72%) ~ 1.23s 1.25s p=0.933 n=6
Check Time 7.18s (± 0.49%) 7.18s (± 0.62%) ~ 7.14s 7.26s p=0.572 n=6
Emit Time 4.36s (± 0.89%) 4.34s (± 0.97%) ~ 4.27s 4.38s p=0.936 n=6
Total Time 14.95s (± 0.35%) 14.94s (± 0.51%) ~ 14.83s 15.03s p=0.873 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,374k (± 0.00%) 476,967k (± 0.01%) +594k (+ 0.12%) 476,897k 477,077k p=0.005 n=6
Parse Time 3.23s (± 0.36%) 3.21s (± 0.79%) ~ 3.18s 3.24s p=0.221 n=6
Bind Time 0.96s (± 0.57%) 0.95s (± 0.86%) ~ 0.94s 0.96s p=0.088 n=6
Check Time 18.00s (± 1.35%) 18.27s (± 0.45%) ~ 18.16s 18.36s p=0.065 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.18s (± 1.09%) 22.43s (± 0.29%) ~ 22.33s 22.48s p=0.063 n=6
xstate - node (v16.17.1, x64)
Memory used 550,659k (± 0.03%) 550,743k (± 0.02%) ~ 550,631k 550,863k p=0.298 n=6
Parse Time 3.95s (± 0.25%) 3.96s (± 0.26%) ~ 3.94s 3.97s p=0.280 n=6
Bind Time 1.80s (± 0.57%) 1.80s (± 0.45%) ~ 1.79s 1.81s p=0.270 n=6
Check Time 3.03s (± 0.93%) 3.11s (± 0.67%) +0.08s (+ 2.59%) 3.07s 3.13s p=0.008 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.86s (± 0.48%) 8.95s (± 0.28%) +0.09s (+ 1.00%) 8.91s 8.98s p=0.012 n=6
Angular - node (v14.15.1, x64)
Memory used 354,905k (± 0.01%) 356,206k (± 0.01%) +1,301k (+ 0.37%) 356,185k 356,242k p=0.005 n=6
Parse Time 3.58s (± 0.33%) 3.60s (± 0.57%) +0.02s (+ 0.60%) 3.58s 3.64s p=0.048 n=6
Bind Time 1.24s (± 0.85%) 1.24s (± 0.94%) ~ 1.23s 1.26s p=0.800 n=6
Check Time 9.75s (± 0.19%) 9.91s (± 0.29%) +0.16s (+ 1.61%) 9.87s 9.95s p=0.005 n=6
Emit Time 8.32s (± 0.55%) 8.34s (± 0.44%) ~ 8.30s 8.38s p=0.627 n=6
Total Time 22.89s (± 0.19%) 23.09s (± 0.32%) +0.20s (+ 0.89%) 23.00s 23.16s p=0.005 n=6
Compiler-Unions - node (v14.15.1, x64)
Memory used 187,802k (± 0.01%) 187,950k (± 0.01%) +148k (+ 0.08%) 187,933k 188,003k p=0.005 n=6
Parse Time 1.60s (± 0.51%) 1.60s (± 0.39%) ~ 1.59s 1.61s p=0.599 n=6
Bind Time 0.85s (± 0.48%) 0.84s (± 0.61%) ~ 0.84s 0.85s p=0.112 n=6
Check Time 10.21s (± 0.53%) 10.22s (± 0.57%) ~ 10.16s 10.32s p=1.000 n=6
Emit Time 3.12s (± 0.60%) 3.13s (± 0.33%) ~ 3.11s 3.14s p=0.287 n=6
Total Time 15.77s (± 0.39%) 15.79s (± 0.38%) ~ 15.71s 15.89s p=1.000 n=6
Monaco - node (v14.15.1, x64)
Memory used 340,534k (± 0.01%) 340,929k (± 0.01%) +394k (+ 0.12%) 340,895k 340,966k p=0.005 n=6
Parse Time 2.83s (± 0.57%) 2.83s (± 0.52%) ~ 2.81s 2.85s p=0.934 n=6
Bind Time 1.10s (± 0.47%) 1.10s (± 0.68%) ~ 1.09s 1.11s p=0.241 n=6
Check Time 8.05s (± 0.17%) 8.06s (± 0.24%) ~ 8.03s 8.08s p=0.459 n=6
Emit Time 4.69s (± 0.62%) 4.67s (± 0.66%) ~ 4.61s 4.69s p=0.372 n=6
Total Time 16.67s (± 0.29%) 16.66s (± 0.30%) ~ 16.58s 16.72s p=0.686 n=6
TFS - node (v14.15.1, x64)
Memory used 294,885k (± 0.00%) 295,301k (± 0.00%) +416k (+ 0.14%) 295,291k 295,313k p=0.005 n=6
Parse Time 2.38s (± 0.43%) 2.40s (± 1.17%) ~ 2.37s 2.43s p=0.365 n=6
Bind Time 1.07s (± 0.51%) 1.07s (± 0.38%) ~ 1.06s 1.07s p=0.282 n=6
Check Time 7.51s (± 0.58%) 7.50s (± 0.28%) ~ 7.47s 7.53s p=0.573 n=6
Emit Time 4.28s (± 0.41%) 4.32s (± 0.82%) ~ 4.28s 4.37s p=0.076 n=6
Total Time 15.24s (± 0.33%) 15.28s (± 0.45%) ~ 15.18s 15.39s p=0.146 n=6
material-ui - node (v14.15.1, x64)
Memory used 472,003k (± 0.00%) 472,502k (± 0.01%) +499k (+ 0.11%) 472,442k 472,545k p=0.005 n=6
Parse Time 3.33s (± 0.49%) 3.35s (± 0.55%) ~ 3.33s 3.38s p=0.241 n=6
Bind Time 1.00s (± 0.54%) 1.00s (± 0.54%) ~ 1.00s 1.01s p=1.000 n=6
Check Time 18.87s (± 0.69%) 19.14s (± 0.62%) +0.27s (+ 1.41%) 19.03s 19.31s p=0.012 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 23.21s (± 0.52%) 23.49s (± 0.52%) +0.28s (+ 1.21%) 23.37s 23.64s p=0.008 n=6
xstate - node (v14.15.1, x64)
Memory used 539,097k (± 0.00%) 539,243k (± 0.00%) +147k (+ 0.03%) 539,220k 539,277k p=0.005 n=6
Parse Time 4.22s (± 0.77%) 4.22s (± 0.28%) ~ 4.20s 4.23s p=0.687 n=6
Bind Time 1.66s (± 0.31%) 1.65s (± 0.71%) ~ 1.64s 1.67s p=0.351 n=6
Check Time 3.19s (± 0.73%) 3.26s (± 0.57%) +0.08s (+ 2.35%) 3.25s 3.30s p=0.005 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 9.15s (± 0.33%) 9.23s (± 0.33%) +0.08s (+ 0.82%) 9.20s 9.28s p=0.005 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-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.15.1, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52495 6
Baseline main 6

TSServer

Comparison Report - main..52495
Metric main 52495 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,387ms (± 0.68%) 2,393ms (± 0.55%) ~ 2,375ms 2,414ms p=0.471 n=6
Req 2 - geterr 5,376ms (± 1.00%) 5,449ms (± 0.52%) +74ms (+ 1.37%) 5,422ms 5,500ms p=0.030 n=6
Req 3 - references 340ms (± 1.34%) 341ms (± 1.22%) ~ 338ms 348ms p=0.627 n=6
Req 4 - navto 279ms (± 0.51%) 281ms (± 0.75%) ~ 278ms 283ms p=0.124 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 79ms (±10.34%) 74ms (± 9.80%) ~ 68ms 86ms p=0.335 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,517ms (± 1.19%) 2,542ms (± 0.99%) ~ 2,513ms 2,580ms p=0.128 n=6
Req 2 - geterr 4,011ms (± 0.95%) 4,030ms (± 0.95%) ~ 3,989ms 4,082ms p=0.378 n=6
Req 3 - references 351ms (± 0.65%) 346ms (± 0.70%) -5ms (- 1.33%) 343ms 349ms p=0.015 n=6
Req 4 - navto 293ms (± 0.22%) 294ms (± 0.90%) ~ 291ms 298ms p=1.000 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 (± 9.32%) 78ms (± 7.07%) ~ 70ms 84ms p=0.570 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,025ms (± 0.42%) 3,033ms (± 0.32%) ~ 3,018ms 3,043ms p=0.296 n=6
Req 2 - geterr 1,589ms (± 0.77%) 1,616ms (± 0.77%) +28ms (+ 1.73%) 1,603ms 1,638ms p=0.013 n=6
Req 3 - references 106ms (± 1.28%) 108ms (± 1.61%) ~ 106ms 111ms p=0.073 n=6
Req 4 - navto 355ms (± 0.56%) 356ms (± 0.78%) ~ 351ms 358ms p=0.325 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 383ms (± 1.00%) 382ms (± 0.56%) ~ 380ms 385ms p=0.684 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,507ms (± 0.62%) 2,513ms (± 0.45%) ~ 2,499ms 2,526ms p=0.423 n=6
Req 2 - geterr 5,772ms (± 0.34%) 5,833ms (± 0.51%) +62ms (+ 1.07%) 5,779ms 5,864ms p=0.020 n=6
Req 3 - references 347ms (± 1.33%) 353ms (± 0.57%) +6ms (+ 1.73%) 351ms 356ms p=0.020 n=6
Req 4 - navto 277ms (± 0.83%) 280ms (± 1.51%) ~ 276ms 287ms p=0.627 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 75ms (± 4.13%) 76ms (± 0.54%) ~ 75ms 76ms p=0.078 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,682ms (± 0.69%) 2,706ms (± 1.17%) ~ 2,680ms 2,759ms p=0.054 n=6
Req 2 - geterr 4,370ms (± 0.28%) 4,376ms (± 0.28%) ~ 4,359ms 4,388ms p=0.378 n=6
Req 3 - references 360ms (± 1.46%) 358ms (± 0.80%) ~ 354ms 362ms p=0.517 n=6
Req 4 - navto 290ms (± 0.31%) 291ms (± 0.74%) ~ 288ms 294ms p=0.683 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 74ms (± 3.80%) 84ms (±12.83%) ~ 68ms 92ms p=0.252 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,172ms (± 0.40%) 3,167ms (± 0.17%) ~ 3,161ms 3,175ms p=0.574 n=6
Req 2 - geterr 1,755ms (± 1.04%) 1,794ms (± 1.08%) +38ms (+ 2.18%) 1,764ms 1,817ms p=0.020 n=6
Req 3 - references 118ms (± 0.35%) 117ms (± 1.79%) ~ 113ms 119ms p=0.528 n=6
Req 4 - navto 339ms (± 0.24%) 343ms (± 0.82%) +3ms (+ 0.98%) 339ms 346ms p=0.028 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 410ms (± 6.57%) 404ms (± 4.35%) ~ 394ms 440ms p=0.468 n=6
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,599ms (± 0.55%) 2,615ms (± 0.59%) ~ 2,600ms 2,636ms p=0.065 n=6
Req 2 - geterr 6,184ms (± 0.45%) 6,211ms (± 0.74%) ~ 6,151ms 6,269ms p=0.298 n=6
Req 3 - references 364ms (± 0.45%) 365ms (± 0.77%) ~ 360ms 368ms p=0.416 n=6
Req 4 - navto 278ms (± 1.60%) 281ms (± 1.95%) ~ 275ms 287ms p=0.806 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.89%) 93ms (±11.17%) ~ 81ms 103ms p=0.462 n=6
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,828ms (± 0.46%) 2,818ms (± 0.53%) ~ 2,802ms 2,838ms p=0.423 n=6
Req 2 - geterr 4,588ms (± 2.83%) 4,581ms (± 2.79%) ~ 4,459ms 4,720ms p=1.000 n=6
Req 3 - references 401ms (± 7.53%) 390ms (± 6.33%) ~ 369ms 422ms p=0.378 n=6
Req 4 - navto 293ms (± 1.33%) 293ms (± 1.87%) ~ 286ms 300ms p=0.872 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 81ms (± 8.87%) 79ms (±10.02%) ~ 73ms 91ms p=0.805 n=6
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 3,456ms (± 0.39%) 3,461ms (± 0.66%) ~ 3,428ms 3,487ms p=0.630 n=6
Req 2 - geterr 1,873ms (± 1.33%) 1,860ms (± 0.35%) ~ 1,849ms 1,869ms p=0.378 n=6
Req 3 - references 126ms (± 1.63%) 124ms (± 2.04%) ~ 122ms 129ms p=0.052 n=6
Req 4 - navto 370ms (± 0.46%) 370ms (± 0.42%) ~ 369ms 373ms p=0.803 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 412ms (± 1.00%) 412ms (± 0.57%) ~ 408ms 414ms p=1.000 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-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.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52495 6
Baseline main 6

Startup

Comparison Report - main..52495
Metric main 52495 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 141.60ms (± 0.19%) 141.57ms (± 0.17%) ~ 140.91ms 144.19ms p=0.260 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 228.10ms (± 0.47%) 226.87ms (± 0.26%) -1.24ms (- 0.54%) 225.17ms 233.06ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 228.76ms (± 0.27%) 228.96ms (± 0.27%) +0.20ms (+ 0.09%) 227.28ms 234.31ms p=0.005 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 210.17ms (± 0.31%) 209.10ms (± 0.17%) -1.07ms (- 0.51%) 208.23ms 213.66ms p=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-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 52495 6
Baseline main 6

Developer Information:

Download Benchmark

@Andarist
Copy link
Contributor Author

So far I managed to analyze 2 of the reported cases.

When it comes to ant-design, I think that this was a good/expected change and that the error was previously somehow suppressed (that part I didn't analyze). I prepared a PR fixing it in this project: ant-design/ant-design#41386

When it comes to react-bootstrap and their BsPrefixRefForwardingComponent, I'm not yet sure what to think about it exactly - but the inferred results now match more closely what is being inferred in case of functions without extra properties. I managed to get a slimmed-down repro of this in this TS playground. We can observe what gets inferred for props at the bottom of it when we toggle on and off defaultProps?: Partial<P> | undefined; at line 88.

There is a notable difference between the inferred props in this playground (after removed .defaultProps) and my change. In the TS playground the props are inferred as:

props // Omit2<any, BsPrefixProps & DropdownItemProps> & BsPrefixProps & DropdownItemProps

and with my change they are:

props // Omit2<React.ComponentPropsWithRef<As>, BsPrefixProps & DropdownItemProps> & BsPrefixProps & DropdownItemProps

Which honestly... looks like an improvement? The signature contained in BsPrefixRefForwardingComponent is generic after all so it feels good that this fact gets preserved with this change.

@weswigham
Copy link
Member

Ooof, definitely going to have to take a peek at the perf cost too (is couldContainTypeVariables cached enough?) - I don't think my teammates would be pleased with a 1.5%-3% performance regression for a bugfix like this :S

@jakebailey
Copy link
Member

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @jakebailey, I've started to run the abridged perf test suite on this PR at 57eb903. You can monitor the build here.

Update: The results are in!

@jakebailey
Copy link
Member

Just rechecking; could be that the diff is due to some bad baseline behavior I'm working on fixing as part of the perf overhaul.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..52495

Metric main 52495 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 361,424k (± 0.01%) 362,820k (± 0.00%) +1,395k (+ 0.39%) 362,803k 362,848k p=0.005 n=6
Parse Time 3.55s (± 0.47%) 3.56s (± 0.97%) ~ 3.49s 3.58s p=0.285 n=6
Bind Time 1.18s (± 0.35%) 1.18s (± 0.54%) ~ 1.17s 1.19s p=0.673 n=6
Check Time 9.51s (± 0.30%) 9.63s (± 0.41%) +0.12s (+ 1.23%) 9.59s 9.69s p=0.005 n=6
Emit Time 7.91s (± 0.55%) 7.94s (± 0.46%) ~ 7.90s 7.99s p=0.226 n=6
Total Time 22.15s (± 0.29%) 22.30s (± 0.41%) +0.15s (+ 0.70%) 22.20s 22.43s p=0.010 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,696k (± 0.87%) 193,247k (± 0.72%) ~ 192,583k 196,094k p=0.810 n=6
Parse Time 1.58s (± 1.04%) 1.58s (± 1.42%) ~ 1.55s 1.61s p=0.870 n=6
Bind Time 0.82s (± 0.77%) 0.82s (± 0.63%) ~ 0.82s 0.83s p=0.386 n=6
Check Time 10.11s (± 0.53%) 10.14s (± 0.50%) ~ 10.08s 10.21s p=0.468 n=6
Emit Time 2.98s (± 0.73%) 2.99s (± 0.69%) ~ 2.96s 3.01s p=0.251 n=6
Total Time 15.49s (± 0.33%) 15.54s (± 0.43%) ~ 15.47s 15.62s p=0.295 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,553k (± 0.01%) 345,986k (± 0.01%) +433k (+ 0.13%) 345,955k 346,036k p=0.005 n=6
Parse Time 2.72s (± 0.60%) 2.72s (± 0.33%) ~ 2.71s 2.73s p=0.801 n=6
Bind Time 1.09s (± 1.00%) 1.09s (± 0.37%) ~ 1.08s 1.09s p=1.000 n=6
Check Time 7.77s (± 0.62%) 7.78s (± 0.33%) ~ 7.74s 7.81s p=0.629 n=6
Emit Time 4.47s (± 0.49%) 4.43s (± 0.39%) -0.04s (- 0.86%) 4.41s 4.45s p=0.016 n=6
Total Time 16.04s (± 0.43%) 16.02s (± 0.24%) ~ 15.96s 16.06s p=0.423 n=6
TFS - node (v16.17.1, x64)
Memory used 299,811k (± 0.01%) 300,205k (± 0.01%) +395k (+ 0.13%) 300,159k 300,247k p=0.005 n=6
Parse Time 2.17s (± 0.63%) 2.18s (± 0.81%) ~ 2.16s 2.20s p=1.000 n=6
Bind Time 1.23s (± 0.68%) 1.24s (± 0.68%) ~ 1.22s 1.24s p=1.000 n=6
Check Time 7.20s (± 0.65%) 7.19s (± 0.36%) ~ 7.15s 7.23s p=0.808 n=6
Emit Time 4.34s (± 0.49%) 4.33s (± 1.04%) ~ 4.28s 4.40s p=0.628 n=6
Total Time 14.95s (± 0.40%) 14.93s (± 0.50%) ~ 14.84s 15.05s p=0.630 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,418k (± 0.00%) 476,947k (± 0.01%) +529k (+ 0.11%) 476,917k 476,975k p=0.005 n=6
Parse Time 3.22s (± 0.50%) 3.19s (± 0.90%) ~ 3.16s 3.23s p=0.141 n=6
Bind Time 0.96s (± 0.57%) 0.97s (± 2.75%) ~ 0.95s 1.01s p=1.000 n=6
Check Time 18.14s (± 0.42%) 18.47s (± 0.67%) +0.33s (+ 1.82%) 18.35s 18.70s p=0.005 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.31s (± 0.32%) 22.63s (± 0.59%) +0.32s (+ 1.43%) 22.51s 22.89s p=0.005 n=6
xstate - node (v16.17.1, x64)
Memory used 550,505k (± 0.02%) 550,686k (± 0.02%) +180k (+ 0.03%) 550,562k 550,799k p=0.020 n=6
Parse Time 3.94s (± 0.14%) 3.94s (± 0.36%) ~ 3.92s 3.96s p=0.250 n=6
Bind Time 1.79s (± 1.12%) 1.80s (± 0.77%) ~ 1.77s 1.81s p=0.869 n=6
Check Time 3.02s (± 1.13%) 3.10s (± 0.70%) +0.08s (+ 2.54%) 3.07s 3.12s p=0.005 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.83s (± 0.46%) 8.92s (± 0.31%) +0.08s (+ 0.96%) 8.88s 8.95s p=0.005 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-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
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 52495 6
Baseline main 6

Developer Information:

Download Benchmark

@jakebailey
Copy link
Member

jakebailey commented Mar 22, 2023

Nope, it's still a perf hit. Bummer.

Though, xstate is a funky test as it is; somehow only 3 seconds of checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on author
Development

Successfully merging this pull request may close these issues.

Optional properties on function interface breaks inference of type parameters
5 participants