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

Does it make sense to throw a type error if the value cannot be null for the .toBeNull helper? #110

Open
CristhianMotoche opened this issue Nov 8, 2023 · 0 comments
Labels
question Further information is requested

Comments

@CristhianMotoche
Copy link
Contributor

CristhianMotoche commented Nov 8, 2023

Does it make sense to throw a type error if a value cannot be null for the .toBeNull helper? For example, in the following test I WOULD expect a type error if the type cannot be null:

  it("cannot be null", () => {
    const x: number = 1;
    expect(x).toBeNull(); # Throw a type error here since `x` can only be a number?
  });

I WOULD NOT expect a type error if the value can be null. For example, in this test:

  it("cannot be null", () => {
    const x: number | null = 1;
    expect(x).toBeNull();
  });

Let me know if that makes sense.

@CristhianMotoche CristhianMotoche changed the title Does it make sense to throw a type error if the value is not null for the .toBeNull helper? Does it make sense to throw a type error if the value cannot null for the .toBeNull helper? Nov 8, 2023
@CristhianMotoche CristhianMotoche added the question Further information is requested label Nov 8, 2023
@CristhianMotoche CristhianMotoche changed the title Does it make sense to throw a type error if the value cannot null for the .toBeNull helper? Does it make sense to throw a type error if the value cannot be null for the .toBeNull helper? Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant