Contravariant parameter types with --strictFunctionTypes breaks IBaseProps
Bug Report
-
Package version(s): 5.17.1
-
Browser and OS versions: all
Are you willing to submit a PR to fix? No
Requested priority: Blocking
Describe the issue:
using tsc strictFunctionTypes (2.6.1) for components deriving from BaseComponent breaks the IBaseProps constraint for componentRef if the property is not signed exactly as in IBaseProps.
so defining
export interface IMyProps extends React.InputHTMLAttributes<HTMLInputElement> {
componentRef?: (ref: IMyComponent | null) => (void | IMyComponent );
...
}
and defining MyComponent that extends BaseComponent and implements IMyComponent fails compilation.
Actual behavior:
tsc: error TS2344: Type 'IMyProps' does not satisfy the constraint 'IBaseProps'
Expected behavior:
no compiler error
Given the circular relationship between IBaseProps and BaseComponent, I'm not sure how IBaseProps can be templated to pass this check
+1
+1
Hey, any news on fixing this issue?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Fabric React!
Sorry for the hassle here. Are you still seeing this issue with the latest package (v5.80.0 as of this writing)? TypeScript support has been updated a few times since this was opened. @manishgarg1 for FYI as we were discussing this in triage.
@dzearing - assigning to you, hopefully Cliff or someone on your team can pick this up?
I just tried this with the latest bits and can build a Foo component just fine using strictFunctionTypes, subclassing BaseComponent, and implementing IFoo which extends IBaseProps. I can use the Foo component in a render, and everything builds correctly.
Closing as no repro, but please re-open if you still have friction!