Skip to content

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

Description

@CristhianMotoche

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions