You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run this through the transpiler, it complains that I'm using the same argument twice in strict mode –– I assume that's a reference to string. Obviously, the flow syntax is not working here. I am wondering how I should type the destructured arguments to make it work. I suppose I could just remove the strict mode pragma.
The text was updated successfully, but these errors were encountered:
As @fkling points out, ({a: string, b: string})=>{...} actually means you wish for the arrow function to take an object with keys a and b and alias them both to a local binding named string. This is a somewhat unfortunate aspect of the JS grammar that we can't really overwrite.
That said, I can't think of a reason why you shouldn't be able to at least annotate the full destructuring pattern:
(it seems Flow currently doesn't parse this)
type funcArg = {a: string, b: string};
var myfunction = ({a, b}:funcArg) => { ... }
@gabelevi Can you think of any reasons why that ^ shouldn't work as a workaround?
Say I have a function that looks like this:
When I run this through the transpiler, it complains that I'm using the same argument twice in strict mode –– I assume that's a reference to
string
. Obviously, the flow syntax is not working here. I am wondering how I should type the destructured arguments to make it work. I suppose I could just remove the strict mode pragma.The text was updated successfully, but these errors were encountered: