Skip to content

Interest in ExtractStrict? #37

@ekilah

Description

@ekilah

Any interest / reason to not want this type added? I can make a PR if so:

type ExtractStrict<T, U extends T> = T extends U ? T : never

context:

Seems like the TS team's reasoning for making their official Omit non-strict included the fact that Extract was also non-strict, which is something I just ran into wanting. Just like OmitStrict, ExtractStrict will get the compiler to help out during refactoring things like this, or to prevent typos in the string keys:

export type TSomeColorOptions = ExtractStrict<TColor, 'blue' | 'whitee'> // should error for typo

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