NagRock / ts-mockito

Mocking library for TypeScript
MIT License
977 stars 93 forks source link

Make objectContaining generic? #149

Open studds opened 5 years ago

studds commented 5 years ago

objectContaining is currently declared as:

function objectContaining(expectedValue: Object): any

Couple of drawbacks:

If the signature was changed to:

function objectContaining<T extends object>(expectedValue: T): T;

both these issues would be resolved, at the cost of complaining about partial objects, so bit of a tradeoff. Personally, I'd prefer to have typechecking in my tests and explicitly cast when required, rather than have everything mapped to any...

I'd be happy to do a PR if there was support for this idea... thoughts?