Issue
I’m coding on a TS project with strictNullChecks
.
I want to make sure that the result of a function is undefined:
const company = await getRepository(Company).findOne({ id: deletedID });
expect(company).toBeUndefined();
^^^^^^^
However, ESLint gives me this warning on the expect line: Passing nullable argument to function that expects non nullable
.
I could also do expect(company === undefined).toBe(true)
but is there a way to use .toBeUndefined()
?
Solution
You can use as
like this:
expect(company as any).toBeUndefined();
Answered By – Sebastian Kaczmarek
Answer Checked By – Willingham (BugsFixing Volunteer)