Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interest in ExtractStrict? #37

Closed
ekilah opened this issue Jul 17, 2019 · 1 comment · Fixed by #38
Closed

Interest in ExtractStrict? #37

ekilah opened this issue Jul 17, 2019 · 1 comment · Fixed by #38

Comments

@ekilah
Copy link
Contributor

ekilah commented Jul 17, 2019

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
@pelotom
Copy link
Owner

pelotom commented Jul 17, 2019

Sure, I'd take a PR for that. Also might as well add ExcludeStrict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants