Closed mmamedel closed 2 years ago
Just thinking better about this, I think it may make more sense to be a function like the is
instead of a type. So I'm changing the subject accordingly.
Good idea, I'll add it asap! I'm thinking make it possible to enable this with ExactProps
, which will delete the property in place, and add another function which validates and clones the data.
Again, thank you so much for adding this library to the benchmarks repo :D, I really didn't expect it to be this fast compared to the rest of the libraries!
Coming back to this -- enabling with ExactProps
wouldn't make much sense when the assertion throws or returns so I'll just make it a parameter to the check
function.
Changed my mind in the end ^, changed it so it's a parameter of the ExactProps
type, if it's set to true, then instead of erroring, the extra properties will be deleted.
Describe the solution you'd like The idea would be to actually remove any additional properties in case they are provided.
Describe alternatives you've considered This could be done by deleting the props from the variable provided. The problem with that is the side-effect created since we would be changing the function parameter. Another option is really copying each one of the props to a new variable. It would be nice if I could use it with
ExactProps
it would be then very similar to a lodash deepClone but with a whitelist of the props given.