quick-lint-js icon indicating copy to clipboard operation
quick-lint-js copied to clipboard

12$: diagnostic: typeof operator should warn when comparing to invalid string literals

Open CoderMuffin opened this issue 11 months ago • 6 comments

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 :)

CoderMuffin avatar Mar 18 '24 15:03 CoderMuffin