I'm using React 16.8 with Typescript "@zeit/next-typescript": "1.1.0"
I have inline-style interface. And There is object using IInputInlineStyle interface.
interface IInputInlineStyle {
padding: string;
textAlign?: string;
paddingLeft?: string | number;
color?: string;
}
const inputInlineStyle: IInputInlineStyle = {
padding,
textAlign
};
But I got this error message.
Error:(155, 21) TS2322: Type 'IInputInlineStyle' is not assignable to type 'CSSProperties'.
Types of property 'textAlign' are incompatible.
Type 'string' is not assignable to type 'TextAlignProperty'.
How can I fix this problem?
Since Typescript 3.4 you can make use of the as const notation:
const inputInlineStyle = {
textAlign: 'center' as const
};
Source - https://github.com/typestyle/typestyle/issues/281#issuecomment-535359254
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With