Loose Equality Comparison (ARCH3195)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
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.
Incorrect
Section titled “Incorrect”function isEmpty(v: unknown): boolean { return v == null || v == "";}Correct
Section titled “Correct”function isEmpty(v: unknown): boolean { return v === null || v === undefined || v === "";}Use the strict === / !== operators for all equality comparisons.