Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function object argument type is incompatible with default #7178

Closed
schibrikov opened this issue Nov 15, 2018 · 2 comments
Closed

Function object argument type is incompatible with default #7178

schibrikov opened this issue Nov 15, 2018 · 2 comments

Comments

@schibrikov
Copy link

schibrikov commented Nov 15, 2018

The thing is when you have an object function argument and specify a default value for it's property with complex type, Flow doesn't recognize type properly.

It may be hard to explain, just check this example: Example

For example, I can't create a function, which accepts object with property that can be either an array of functions or a single function.

For those who want a quick look:

type MyType = number[] | number;

function myfunc({
  // Here flow screams that default arg is incompatible with number (WTF?)
  arg = 3,
}: { arg: MyType }) {
  console.log(arg);
}
@schibrikov
Copy link
Author

bump! Still reproducible in 0.9X. Can someone explain why is this happens?

@goodmind
Copy link
Contributor

Duplicate of #2093

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants