Skip to content

Inconsistent overload parameters when generic never is present #140

@kade-robertson

Description

@kade-robertson

Not sure if the title makes it super clear what I'm experiencing -- essentially, when using function overloads, where one of the parameters is never typed in one overload, but has a well-defined type in another overload, two different behaviours can occur:

  • If the return type does not depend on the generic, the parameter type appears to be correctly resolved as the well-defined type.
  • If the return type does depend on the generic, the parameter type is resolved as never. (After further investigation, this might just happen any time the return type is never)

Playground Link

This seems to have started happening after the overhaul to overloaded types was released in v0.20.0 -- in the previous version, this inconsistency didn't occur.

My understanding is that given T | never == T, the parameter type should resolve to whatever the non-never type is. In any case, I would have expected both of these to return the same thing, but maybe this is a bad expectation.

This is reasonably easy to work around by adding a dummy value that prevents the never type, so I'm not particularly fussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions