# valid-typeof
Enforce the use of valid string literals in a typeof comparison.
typeof can only return a small set of strings, undefined, object,
boolean, number, string or function, and if you provide
an invalid value, it’s most likely a typo, and the comparison
will always return false.
This behaviour will be denied by this rule.
# Invalid Code Examples
typeof foo === "strnig"
typeof foo == "undefimed"
typeof bar != "nunber"
typeof bar !== "fucntion"
# Config
| Name | Type | Description |
|---|---|---|
requireStringLiterals | bool | * If this option is true, typeof expression can only be compared* to valid string literals, or other typeof expressions, but* can not be compared to any other value. |
More incorrect examples
typeof foo === "strnig"
typeof foo == "undefimed"
typeof bar != "nunber"
typeof bar !== "fucntion"
More correct examples
typeof foo === "string"
typeof bar == "undefined"
typeof foo === baz
typeof foo === 4
typeof bar === typeof qux