-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Exact Object #319
Comments
Ah, looking closer at the implementation + tests of import { Exact } from 'ts-toolbelt/out/Function/Exact'
function exactObject<A>(x: Exact<A, {a: number, b: 2}>) {}
// ok
exactObject({} as {a: 1, b: 2})
// errors
exactObject({} as {a: 1, b: 2, c: 3})
exactObject({} as {a: 1}) Since the tests for I am happy to receive any more background info about exact types here, but I think this issue can now be closed? |
Thank you! |
Glad to help! Let me know what you think of #320 :) |
🍩 Feature Request
Is your feature request related to a problem?
It would be great to have an exact object / interface utility type as a part of
ts-toolbelt
- preventing any fewer properties or excess properties passed in an object - such as:This is one of the top-requested features in TypeScript itself, but does not yet exist in the language.
Describe the solution you'd like
A new exported
Object/Exact
utility type to allow for checking against exact typesDescribe alternatives you've considered
I saw
Function/Exact
, but this appears to be something different... This docs page does use some of the same words when describing the problem, which at first seems to indicate it's the right thing:...but I don't understand how / where I would apply this
Exact<A, W>
generic signature. 🤔Teachability, Documentation, Adoption, Migration Strategy
For implementation of the utility, some of the answers in the TypeScript issue are potentially useful:
The code block in the first section above could be used an example in the docs for the type.
The text was updated successfully, but these errors were encountered: