Type issue: "Types of property 'display' are incompatible." for IRawStyleBase
Environment Information
- Package version(s): TS 3.3.3, office-ui-fabric-react 6.146.1
- Browser and OS versions: (fill this out if relevant)
Please provide a reproduction of the bug in a codepen:
I don't see the errors in the codepen but here it is regardless (thanks to Micah for helping with the styles on this): https://codepen.io/rashaf/pen/oRJbRE
Actual behavior:
Type error:
TS2322: Type '{ calloutProps: { styles: { beak: { background: string; }; beakCurtain: { background: string; }; }; }; styles: { root: { borderColor: string; background: string; color: string; display: string; }; content: { ...; }; }; }' is not assignable to type 'ITooltipProps'.
Types of property 'styles' are incompatible.
Type '{ root: { borderColor: string; background: string; color: string; display: string; }; content: { background: string; }; }' is not assignable to type 'IStyleFunction<ITooltipStyleProps, ITooltipStyles> | Partial<ITooltipStyles> | undefined'.
Type '{ root: { borderColor: string; background: string; color: string; display: string; }; content: { background: string; }; }' is not assignable to type 'Partial<ITooltipStyles>'.
Types of property 'root' are incompatible.
Type '{ borderColor: string; background: string; color: string; display: string; }' is not assignable to type 'IStyle'.
Type '{ borderColor: string; background: string; color: string; display: string; }' is not assignable to type 'IRawStyle'.
Types of property 'display' are incompatible.
Type 'string' is not assignable to type '"ruby" | "table" | "flex" ...
From what I can tell this comes from IRawStyleBase.ts. Not sure why this is throwing a type error when "inline-block" is clearly one of the values.
const red = theme.palette.redDark;
const tooltipProps = {
calloutProps: {
styles: {
beak: { background: red },
beakCurtain: { background: red }
}
},
styles: {
root: {
borderColor: red,
background: red,
color: theme.palette.white,
display: "inline-block" // THIS LINE PRODUCES THE TYPE ERROR
},
content: { background: red }
}
};
return (
<RenameFileFormContainer>
<TooltipHost
content={
actionFailureText !== ""
? actionFailureText
: this.state.tooltipText
}
directionalHint={DirectionalHint.bottomAutoEdge}
tooltipProps={tooltipProps}
calloutProps={{ gapSpace: 0 }}
closeDelay={5000}
styles={{ root: { display: "inline-block" } }} // WORKS FINE WHEN WRITTEN HERE
>
...
`
#### Expected behavior:
Should be able to include `root: { display: "inline-block" }` in the tooltipProps style.
#### Priorities and help requested:
Are you willing to submit a PR to fix? Maybe
Requested priority: Low
Products/sites affected: (if applicable)
This is because a type is not declared when tooltipProps object is created, so TypeScript infers the type of display as string.
Can you try the following?
const tooltipProps: ITooltipHostProps = {
...
};
That should get rid of the error for you. Thanks!
This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!