valid-typeof
Configuration
rslint.config.ts
Rule Details
Enforces comparing typeof expressions against valid string literals. The typeof operator can only return one of the following strings: "undefined", "object", "boolean", "number", "string", "function", "symbol", "bigint". Comparing a typeof expression against any other value is almost certainly a bug.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
requireStringLiterals
When set to true, requires that typeof expressions are only compared to string literals or other typeof expressions, and disallows comparisons to any other value.
Examples of additional incorrect code with { "requireStringLiterals": true }: