Ben Aston
Ben Aston

Reputation: 55749

How to solve "destructuring. Missing annotation" in FlowType?

The following code:

export const myFunction = ({ option1, option2 }) => {};

...gives:

destructuring. Missing annotation

I do not want to have to create a Type specifically for the options object supplied to myFunction - this seems unnecessary, adds noise to the code and and will be a maintenance headache - can I achieve this and eliminate this FlowType error, or is this "how FlowType works"?

Upvotes: 3

Views: 556

Answers (1)

Ben Aston
Ben Aston

Reputation: 55749

There is an inline syntax:

export const myFunction = ({ option1, option2 }: { option1: string, 
    option2: Array<string> } ) => {};

Looks horrible to my eye - if you want static typing, use a statically typed language?

Upvotes: 1

Related Questions