fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Contravariant parameter types with --strictFunctionTypes breaks IBaseProps

Open fuocor opened this issue 9 years ago • 7 comments

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

fuocor avatar Nov 01 '17 17:11 fuocor

+1

Syntarex avatar Nov 10 '17 15:11 Syntarex

+1

WHKFZYX-Tool avatar Nov 28 '17 14:11 WHKFZYX-Tool

Hey, any news on fixing this issue?

lednhatkhanh avatar Dec 09 '17 01:12 lednhatkhanh

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!

stale[bot] avatar Apr 11 '18 07:04 stale[bot]

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.

Jahnp avatar Apr 11 '18 18:04 Jahnp

@dzearing - assigning to you, hopefully Cliff or someone on your team can pick this up?

aditima avatar May 10 '18 20:05 aditima

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!

dzearing avatar Jun 21 '18 06:06 dzearing