TS2367
This condition will always return 'false' since the types '{ message: string; }[] | undefined' and 'number' have no overlap.
Broken Code ❌
function myTest(errors: { message: string }[]): void {
if (errors === 0) {
throw new Error();
}
}Fixed Code ✔️
An array cannot be 0, so doing a check for equality with 0 makes no sense. What may be useful instead is checking the array length:
function myTest(errors: { message: string }[]): void {
if (errors.length === 0) {
throw new Error();
}
}