GithubHelp home page GithubHelp logo

Comments (8)

vjeux avatar vjeux commented on April 19, 2024
function length() { ... }
length("Hello")

Flow should warn that you're calling a function that takes 0 arguments with 1 argument no?

from flow.

dugokontov avatar dugokontov commented on April 19, 2024

It is a valid point, but issue still exist with updated example:

/* @flow */
var x = null;
function length() {
    if (x === null || x === undefined) {
        return 0;
    }
    return x.length;
}

var total = length();

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

Please use x == null as a workaround. (Known issue about Flow not understanding === undefined.)

from flow.

avikchaudhuri avatar avikchaudhuri commented on April 19, 2024

Merging with #21

from flow.

dugokontov avatar dugokontov commented on April 19, 2024

It looks like this is something else, since this doesn't work even with with x == null

/* @flow */
var x = null;
function length() {
    if (x == null) {
        return 0;
    }
    return x.length;
}

var total = length();

I still get

nulls.js:7:16,23: property length
Property cannot be accessed on possibly null value
nulls.js:2:13,16: null

As I said before, I don't get this error when var x = null; is inside function length

from flow.

arb avatar arb commented on April 19, 2024

@dugokontov did you ever find a solution to this? I'm noticing this issue now with early returns and nullable input arguments.

from flow.

dugokontov avatar dugokontov commented on April 19, 2024

@arb no ):
For some reason @avikchaudhuri closed this issue a long time ago...

from flow.

linuxonrails avatar linuxonrails commented on April 19, 2024

I have the same problem :-(

from flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.