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

Checking !== undefined should suffice for an optional argument #21

Closed
sophiebits opened this issue Nov 18, 2014 · 2 comments
Closed

Checking !== undefined should suffice for an optional argument #21

sophiebits opened this issue Nov 18, 2014 · 2 comments
Assignees

Comments

@sophiebits
Copy link
Contributor

This code doesn't type-check:

/* @flow */

function foo(x?: string): string {
    if (x !== undefined) {
        return x;
    }
    return "meow";
}

Changing the conditional to x != null makes the code work, but I believe checking against undefined should suffice because the argument type itself isn't nullable. Also: != undefined doesn't work even though it has the same meaning as != null.

@avikchaudhuri
Copy link
Contributor

Known issue, will fix.

@gabelevi
Copy link
Contributor

@avikchaudhuri fixed this awhile back when he revamped optional types in v0.2.0. Sorry for forgetting to close out the issue!

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

3 participants