Skip to content

Allow Exclude when the difference contains a union. #23862

Closed
@estaub

Description

@estaub

AFAICT, there is no broadly-functional implementation of Exclude/Omit that works when there's a union in the remaining difference. I'd suggest that perhaps Exclude might be enhanced to handle this case.

The Omit implementations I'm aware of rely on keyof, which doesn't include any members of one union member that aren't present in all. This is by design; see #12948.

2.8's Exclude won't work on such a type at all, complaining that it's not an interface.

This blocked one route in my particular production (one of many!) of "The Failed Quest for a Typescript React HOC Declaration With Generic Inferencing That Works". See mui/material-ui#11003 (likely to be rolled back soon).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions