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

false positive bug #5135

Closed
kentcdodds opened this issue Oct 18, 2017 · 2 comments
Closed

false positive bug #5135

kentcdodds opened this issue Oct 18, 2017 · 2 comments

Comments

@kentcdodds
Copy link

Hi there! I'm still so new at Flow that I honestly have no idea how to describe this bug, but here's a reproduction

/* @flow */

type Element = {};
type Document = {getElementById(string): Element | null};

declare var document: Document;

type InitOptions = {
  messagesNode?: Element | void
}

function init({
  messagesNode = document.getElementById('react-messages')
}: InitOptions) {
  // blah blah
  return messagesNode
}

function workingInit(options: InitOptions) {
  const {
    messagesNode = document.getElementById('react-messages')
  } = options
  // blah blah
  return messagesNode
}

For some reason, moving the destructuring from the param list to the function body works. I'm pretty sure that this is a bug. Or I'm just doing something dumb 🤷‍♂️

Thanks!

@kentcdodds
Copy link
Author

Ah, looks like this might be related: #183

Feel free to close if you'd like

@Jacse
Copy link

Jacse commented Oct 22, 2017

This is definitely a complete duplicate of #183 so I think you should close this issue and we'll focus our efforts on the original one.

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

No branches or pull requests

2 participants