Skip to content

Variadic function type signatures are selected by ordering in lib files #2360

@justinwoo

Description

@justinwoo

I tried asking around and didn't find answers about this behavior other than the flow-typed rxjs typings that describe this defect.

As of 0.31, variadic functions' type signatures aren't selected correctly and the earliest entries will end up being used. This meaning that if I have a typing for the same function for two or three arguments, if the two-arg definition is above the three-arg definition, it will be picked even when using three.

It seems like you can get around this by reversing your definition ordering, but I'm guessing that probably opens a whole 'nother can of worms (if not, it's still not great).

Edit2: Oh, yes, looks like I was really wrong about this, it just matches on the first one The tooltip is wrong, it really does seem to match the correct signature but only if the ordering is reverse from highest number of args going down:

Is this to be expected and solvable in another way, or is this actually a defect?

Repo with more details: https://github.com/justinwoo/flow-type-select-ordering

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions