stackbuilders / stackbuilders/assertive-ts

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

Open
#110 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
TypeScript
Stars
37
Forks
4
Avg merge
7d 9m
Merged PRs (30d)
2

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the .toBeNull helper and the TypeScript examples in the issue. The work first needs a decision on whether non-nullable values should produce a type error, followed by defining and verifying the expected behavior for nullable and non-nullable values.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.