-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Proposal: Exact
and ExactDeep
#156
Comments
Yeah, those sound like useful types for me. It's the kind of types I didn't know I needed. PR welcome if anyone wants to implement this. Please follow: https://github.com/sindresorhus/type-fest/blob/master/.github/contributing.md |
Exact
and ExactDeep
I see no clean way to implement this type. In my mind the perfect solution would be I'd love to see someone tackle this, godspeed my friend. |
Hi @stephenh do you have an example that you need to differentiate I was trying to implement an But this type As @kainiedziela suggested I don't see there is a way to implement it without |
@zorji hey! Nope, I'd be fine with just Really great to here you're working on this. FWIW I copied your current version into a project that is perhaps a little too fancy with mapped types and ran into these two reproductions:
I was able to fix both of these by adding a very naive
Which, AFAICT does not break any of the other tests. Not sure if that's okay/the best way or not, but FWIW thought I would mention it, and if anything maybe provide a few examples of "the type you're trying to Exact is a mapped type". Thanks! |
I also get this fun guy: :-) However it must be something esoteric with our project-specific
|
Hi! Not sure if you take requests, but I've wanted an
Exact
type in TS for awhile, primarily to model wire calls (i.e. HTTP / DB / RPC calls) where the TS semantics of "including a few extra keys won't hurt" is (imo) not the best b/c it can make the caller think it's data is going over the wire, when really unknown keys are being dropped.There is a TS issue about this:
microsoft/TypeScript#12936
And a few ways of doing a non-deep
Exact
that all look good / work great afaict.However, at least to my initial efforts/attempts, a
DeepExact
/ExactDeep
is more nuanced / not available / solved yet, where, similar to your impl ofPartialDeep
, values of map/array/set/etc. all need to be handled differently/recursively.Upvote & Fund
The text was updated successfully, but these errors were encountered: