Skip to content

Docs: documented use of function return type conditional on argument type is impractical #1931

Closed as not planned
@msbit

Description

@msbit

Page URL:

https://www.typescriptlang.org/docs/handbook/2/conditional-types.html

Issue:

The example showing use of return type conditional on argument type near

We can then use that conditional type to simplify our overloads down to a single function with no overloads.
will compile, but as indicated by the trajectory of microsoft/TypeScript#24929 a type safe function body is not possible.

Recommended Fix:

I can see a few options, either:

  • provide a type safe implementation (which is seemingly not possible)
  • provide an implementation with one of the unsafe workarounds (returning as any, reinstating the overloads, possibly others)
  • remove the specific use of conditional types as a return type dependent on an argument type (preferably with a specific call out that this is not supported, for those who go looking)

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