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

Loosen type constraints for deepEqual assertion #2969

Merged
merged 1 commit into from Mar 6, 2022

Conversation

RebeccaStevens
Copy link
Contributor

fix #2964

@novemberborn
Copy link
Member

Cheers @RebeccaStevens. Could you add a test for this under https://github.com/avajs/ava/tree/main/test-d?

@RebeccaStevens
Copy link
Contributor Author

Cheers @RebeccaStevens. Could you add a test for this under main/test-d?

Sure thing. Give me a few minutes.

@RebeccaStevens
Copy link
Contributor Author

@novemberborn Done

test-d/deep-equal.ts Outdated Show resolved Hide resolved
* Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
* `expected`, returning a boolean indicating whether the assertion passed.
*/
<Actual, Expected>(actual: Actual, expected: Expected, message?: string): boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this overload? Wouldn't the assertion always fail if neither extend one another?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If part of Expected extends part of Actual, but another part Expected is a super type of Actual, then neither extends the other but both my have the same value.

For example, imagine that one of the properties on Expected is typed as readonly, while the corresponding property on Actual isn't. And then for another property the two share, the readonlyness is declared the other way around.

@novemberborn novemberborn changed the title fix(DeepEqualAssertion): allow Actual to extend Expected rather requiring that it must be the other way around Loosen type constraints for deepEqual assertion Mar 6, 2022
@novemberborn novemberborn merged commit 9f797b0 into avajs:main Mar 6, 2022
@novemberborn
Copy link
Member

Thanks @RebeccaStevens!

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 this pull request may close these issues.

Support Actual extends Expected in conjunction with Expected extends Actual
2 participants