quick-lint-js
quick-lint-js copied to clipboard
12$: diagnostic: typeof operator should warn when comparing to invalid string literals
When performing checks like typeof x == "string"
, it is perfectly possible to misspell it as something like typeof x == "strng"
(missing i
), which will always return false. Maybe there should be a warning for this?
More generally, expressions of the form typeof <a> [== or != or === or !==] <b>
where b is a string and not "undefined"
, "object"
, "boolean"
, "number"
, "bigint"
, "string"
, "symbol"
or "function"
I would be happy to implement this if approved and no-one else wants to :)