Skip to content

Loose Equality Comparison (ARCH3195)

Key typescript.quality.loose-equality · Severity warning · Category quality

The == and != operators perform type coercion, producing surprising results like 0 == "" or null == undefined. The type-safe === and !== should be used instead.

function isEmpty(v: unknown): boolean {
return v == null || v == "";
}
function isEmpty(v: unknown): boolean {
return v === null || v === undefined || v === "";
}

Use the strict === / !== operators for all equality comparisons.