Reputation: 746
I'm defining the following function:
const Text = ({
align = 'left',
children,
className,
color = 'middleGrey',
size = 'big',
light = false,
}: Props) => ()
And as I'm using typescript, I have defined the following interface:
interface Props {
align: string
children: ReactNode
className: string
color: string
size?: string
light: boolean
}
But this makes me write 2 times every property.
Is there a better way to write this kind of code?
Upvotes: 2
Views: 66
Reputation: 249546
Unfortunately not. Destructuring syntax does not support specifying type annotations. There is an issue on this topic but it is open and not particularly active.
Upvotes: 5